我有一个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.logDockerfile:
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
...发布于 2018-12-20 21:00:58
我有一个类似的问题,我设法通过更改以下内容来解决:
"start: "react-scripts start"
至:
"start: "./node_modules/.bin/react-scripts start"
在scripts部分package.json中。
我使用的是经典的基于节点的图像,但它的工作原理应该大致相同。
我仍然在调查为什么NPM在Docker中运行时不能解析react-scripts,欢迎任何进一步的帮助:-)
发布于 2020-12-09 07:45:31
当package.json文件中的'devDependencies‘下面列出了'react-scripts’时,我就遇到了这种情况。将它移到“依赖项”部分解决了这个问题。
发布于 2021-02-09 00:09:07
在构建容器之前,删除package-lock.json并使用npm install重新安装包为我解决了这个问题。
https://stackoverflow.com/questions/50920521
复制相似问题