我有一个Docker容器无法为react.js应用程序执行npm安装,该应用程序在构建时克隆在容器中。有人知道如何解决这个问题吗?
错误:
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: `react-scripts build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build 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/2018-06-19T04_00_09_065Z-debug.log
Dockerfile:
FROM ubuntu
Run apt-get update
Run apt-get install curl -y
Run curl -sL https://deb.nodesource.com/setup_10.x
Run apt-get install -y nodejs
Run apt-get install -y git
Run apt-get install npm -y
Run apt-get update -y
Run git clone https://github.com/sdrafahl/TerraWeb.git
WORKDIR /TerraWeb
Run npm install -g --save npm@latest
...
我有类似的问题,我设法改变:
"start: "react-scripts start"
至:
"start: "./node_modules/.bin/react-scripts start"
在scripts
部分package.json
。
我使用经典节点基础映像,但它应该或多或少相同。
我仍在调查为什么NPM在Docker内部运行时无法解析react-scripts
,非常欢迎任何进一步的帮助:-)