“sh: 1: react-scripts: not found” 在 Docker 中

SPD*_*SPD 8 docker reactjs

我有一个 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! myrideweb@0.1.0 build: `react-scripts build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the myrideweb@0.1.0 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
Run Code Online (Sandbox Code Playgroud)

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

...
Run Code Online (Sandbox Code Playgroud)

mar*_*peg 9

我有一个类似的问题,我设法通过更改来解决:

"start: "react-scripts start"

到:

"start: "./node_modules/.bin/react-scripts start"

在该scripts部分package.json

我使用经典的节点基础映像,但它的工作方式应该或多或少相同。
而且我仍在调查为什么 NPMreact-scripts在 Docker 中运行时无法解决,非常欢迎任何进一步的帮助:-)