Hướng dẫn can t install react html parser - t có thể cài đặt trình phân tích cú pháp html phản ứng không

Tôi đang cố gắng cài đặt react-html-parser trong 'client' của container ': khách hàng':

docker-compose.yml
client/
      Dockerfile-dev
      node_modules/
      src/   
         components/
                   Seeds.jsx

và thử và nhập nó vào đây:

Seeds.jsx

import React, { Component } from 'react';
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 }
from 'react-html-parser';
import axios from 'axios';

'axios''react' được in ngay, nhưng không phải

import React, { Component } from 'react';
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 }
from 'react-html-parser';
import axios from 'axios';
0. Bảng điều khiển ghi lại cho tôi lỗi:

index.js:1437 ./src/components/Seeds.jsx
Module not found: Can't resolve 'react-html-parser' in '/usr/src/app/src/components'

package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "react": "^16.8.2",
    "react-dom": "^16.8.2",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.5",
    "react-html-parser":"^2.0.2", # <---------NEW
    "spotify-web-api-js": "^0.22.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "enzyme": "^3.8.0",
    "enzyme-adapter-react-16": "^1.7.1"
  }
}

Dockerfile-dev

# base image
FROM node:11.6.0-alpine

# set working directory
WORKDIR /usr/src/app

# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH

# install and cache app dependencies
COPY package.json /usr/src/app/package.json

RUN npm install --silent
RUN npm install  -g --silent

# start app
CMD ["npm", "start"]

docker-compose.yml

  client:
    build:
      context: ./services/client
      dockerfile: Dockerfile-dev
    volumes:
      - './services/client:/usr/src/app'
      - '/usr/src/app/node_modules'
    ports:
      - 3000:3000
    environment:
      - NODE_ENV=development
      - REACT_APP_WEB_SERVICE_URL=${REACT_APP_WEB_SERVICE_URL}
    depends_on:
      - web

Tôi không thể tìm thấy mô -đun bên trong thư mục

import React, { Component } from 'react';
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 }
from 'react-html-parser';
import axios from 'axios';
1 của mình ...

Tôi còn thiếu gì ở đây?


Chỉnh sửa: NPM Cài đặt mà không có - -Silent:: npm install without --silent:

npm WARN deprecated : Way too old
npm WARN deprecated : core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
npm WARN deprecated : This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated : CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated : Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm WARN deprecated : I wrote this module a very long time ago; you should use something else.
npm WARN deprecated : This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated : This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated : use String.prototype.padStart()

>  postinstall /usr/src/app/node_modules/core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


>  postinstall /usr/src/app/node_modules/core-js-pure
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN  requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY:  (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for : wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY:  (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for : wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

Phản ứng HTML là gì?

Một tiện ích để chuyển đổi chuỗi HTML thành các thành phần phản ứng. Tránh việc sử dụng DangeroSsetInnerHTML và chuyển đổi các yếu tố HTML tiêu chuẩn, thuộc tính và kiểu nội tuyến thành các tương đương phản ứng của chúng.. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents.

Phản ứng HTML có an toàn không?

React-HTML-Parser có an toàn để sử dụng không?Gói NPM React-HTML-Parser đã được quét cho các lỗ hổng đã biết và giấy phép bị thiếu, và không có vấn đề gì được tìm thấy.Do đó, gói được coi là an toàn để sử dụng.the package was deemed as safe to use.

Làm thế nào thêm HTML vào ReactJS?

Chỉ cần sử dụng mẫu React-Create-app và những thứ HTML (đầu, meta) cơ bản đã được đưa ra, chỉ cần sửa đổi Dir SRC để đáp ứng nhu cầu của bạn.ví dụ chỉ số.JS sẽ là một cái gì đó như thế này, nhập phản ứng từ 'React';Nhập './app.use react-create-app template and the basic html (head, meta) things are already in place, Just modify the src dir to meet you needs. for example the index. js would be something like this, import React from 'react'; import './App.

Làm thế nào phản ứng chuyển đổi JSX thành HTML?

Conclusion..
Mỗi thẻ JSX được chuyển đổi thành React.....
Biểu thức JSX, được viết bên trong dấu ngoặc xoăn, chỉ cho phép những thứ đánh giá theo một số giá trị như chuỗi, số, phương thức bản đồ mảng, v.v.
Trong React, chúng ta phải sử dụng ClassName thay vì lớp để thêm các lớp vào phần tử HTML ..