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