首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker中的"sh: 1: react-scripts: not found“

Docker中的"sh: 1: react-scripts: not found“
EN

Stack Overflow用户
提问于 2018-06-19 12:09:25
回答 6查看 9.7K关注 0票数 10

我有一个Docker容器,它无法为构建时克隆到容器中的react.js应用程序执行npm安装。有人知道如何解决这个问题吗?

错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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

...
EN

回答 6

Stack Overflow用户

发布于 2018-12-20 21:00:58

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

"start: "react-scripts start"

至:

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

scripts部分package.json中。

我使用的是经典的基于节点的图像,但它的工作原理应该大致相同。

我仍然在调查为什么NPM在Docker中运行时不能解析react-scripts,欢迎任何进一步的帮助:-)

票数 9
EN

Stack Overflow用户

发布于 2020-12-09 07:45:31

当package.json文件中的'devDependencies‘下面列出了'react-scripts’时,我就遇到了这种情况。将它移到“依赖项”部分解决了这个问题。

票数 0
EN

Stack Overflow用户

发布于 2021-02-09 00:09:07

在构建容器之前,删除package-lock.json并使用npm install重新安装包为我解决了这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50920521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档