reactjs - "sh: 1: react-scripts: not found"在 Docker 中

标签 reactjs docker

我有一个 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

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

...

最佳答案

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

“开始:”react-scripts开始”

至:

“开始:”./node_modules/.bin/react-scripts开始”

scripts部分package.json中。

我使用经典的节点基础镜像,但它的工作原理应该大致相同。
我仍在调查为什么 NPM 在 Docker 内运行时无法解析 react-scripts,非常欢迎任何进一步的帮助:-)

关于reactjs - "sh: 1: react-scripts: not found"在 Docker 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50920521/

相关文章:

reactjs - React Router - 更新版本后 withRouter 上的 Typescript 错误

java - 任务:react-native-gesture-handler:compileDebugJavaWithJavac FAILED

reactjs - 如何在多个钩子(Hook)中等待多个状态更新?

javascript - 如何使用 React Router 获取路由处理程序上的参数

javascript - 如何避免嵌套的三元运算符

docker - 如何在 docker 容器中运行 cron 作业?

Jenkins :无法连接到 Docker 守护进程

azure - 如何从现有的azure容器注册表中提取镜像?

docker - Dockerfile:如何获取Anaconda

python - 如何在 Docker 容器中对进程进行 numactl membind?