我正在尝试react-html-parser
在我的docker容器’client’中安装:
docker-compose.yml
client/
Dockerfile-dev
node_modules/
src/
components/
Seeds.jsx
并尝试在这里导入:
Seeds.jsx
import React, { Component } from 'react';
import ReactHtmlParser, { processNodes, convertNodeToElement, htmlparser2 }
from 'react-html-parser';
import axios from 'axios';
'axios'
并且'react'
可以安装,但是不是'react-html-parser'
。控制台将错误记录给我:
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开发
# 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 react-scripts@2.1.2 -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
我在node_modules
文件夹中找不到模块…
我在这里想念什么?
编辑 :不带–silent的npm安装:
npm WARN deprecated fsevents@1.2.4: Way too old
npm WARN deprecated core-js@2.6.4: 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 joi@11.4.0: 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 circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated kleur@2.0.2: 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 flatten@1.0.2: I wrote this module a very long time ago; you should use something else.
npm WARN deprecated hoek@4.2.1: 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 topo@2.0.2: 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 left-pad@1.3.0: use String.prototype.padStart()
> core-js@2.6.9 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 -)
> core-js-pure@3.1.3 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 ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
当您的docker-compose.yml
文件说:
volumes:
- '/usr/src/app/node_modules'
您是在告诉Docker您的node_modules
目录包含关键数据,这些关键数据需要在容器运行期间保持不变。首次启动容器时,它将从映像中填充该容器,但是由于该目录包含关键数据,因此即使您尝试npm install
添加其他模块,Docker也将永远不会再次对其进行更新。
对于近期的解决方法,这对于docker-compose stop; docker-compose rm; docker-compose up --build
您的容器就足够了。删除现有容器(及其匿名卷)很重要。
问题内容: 我正在使用Babel和Webpack开发一个React应用,我想使用npm中的软件包。我已经安装了该软件包并将其保存为项目的依赖项。运行npm start后,出现此错误: ./~/file-exists/index.js中的错误找不到 模块:错误:无法在C:\ GitHub \ CryptoPrices \ node_modules \ file-exists @ ./~/file-e
我试图安装一个登录与LinkedIn功能到React应用程序。因此,我使用了并运行了,考虑到当前版本的react-领英-login-oAuth2安装不工作。在添加了GitHub自述文件中建议的示例文件后,作为测试应用程序的一种手段,似乎找不到该模块。 编译失败。 ./src/App。未找到js模块:无法解析“D:\workspace\kekap\src”中的“react-linkedin-logi
问题内容: 我见过几篇与此类型的错误相关的文章。但是我无法解决。 我的package.json: 我在webpack上遇到以下错误: 但是在我做的cmd行中 我得到3.10.10。反应场在那里。但是我不知道为什么它仍然会给出这个错误。 当我通过npm安装“ npm install react-dom”并运行webpack时,出现以下错误: 请帮忙。 问题答案: 未安装Issue ,当您点击时,它会
我正在尝试使用 来为我的 react 应用程序的一小部分提供服务。我有两个部分(和),但我只对部分有顾虑。 我尝试了以下方法: > 在根目录下创建文件 我添加了来忽略babel,因为我无法使它导入文件,它不断抛出: 。 但是,每次我运行webpack时,它都会抛出诸如以下的错误: 位于这个根文件夹中。
后,浏览器给出错误: 编译 ./src/components/App/App.js 找不到模块:无法解析 'react-router-dom'。 React-router-dom 已被添加到 npm 中的依赖项中,react-router 和 react 也是如此。 已经使用< code > create-react-app myapp cmd行创建了项目。这在本地主机节点服务器上运行。我的项目文
问题内容: 我不敢相信我在问一个明显的问题,但在控制台日志中仍然出现错误。 控制台表示无法在目录中找到该模块,但是我至少检查了10次错别字。无论如何,这是组件代码。 我想在根中渲染 Header 这是组件 我至少检查了10次该模块是否在此位置(文件夹“ header”包含“ header.js”)。 然而,React仍然抛出此错误: 编译失败 NPM测试 说的是同样的话。 问题答案: 我们通常使用