包含ReactJS App的Docker容器在本地运行,但在Web服务器上失败

时间:2019-09-06 10:09:26

标签: reactjs docker npm production

运行命令时:

docker run -p 80:3200 greenandeasy-website

在webservers ssh终端中出现以下错误:

  

greenandeasy-webapp@0.1.0开始/ greenandeasy-website   节点./node_modules/react-scripts/bin/react-scripts.js start

module.js:549     犯错     ^

Error: Cannot find module '/greenandeasy- 
website/node_modules/react-scripts/bin/react-scripts.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! greenandeasy-webapp@0.1.0 start: `node 
./node_modules/react-scripts/bin/react-scripts.js start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the greenandeasy-webapp@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely . 
additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did 
you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-09-05T21_00_36_494Z-debug.log

我了解它没有找到react-scripts.js,但我想知道为什么完全相同的命令在本地机器上起作用而不在服务器上起作用。

感谢您提供一些解决此问题的想法;)

dockerfile:

FROM node:6-wheezy

WORKDIR /src/green-and-easy/

COPY package.json package-lock.json ./

RUN npm install

COPY . .

EXPOSE 80

ENV NODE_JS_PORT=80

CMD [ "npm", "start" ]

0 个答案:

没有答案