不能将图像作为容器运行
我成功地创建了项目的图像。但是,当我想将此映像作为容器运行时,我会收到以下错误,
> [email protected] start
> react-scripts start
sh: react-scripts: not found
我的docker文件就是这样:
FROM node:16.14-alpine3.14
WORKDIR /frontend
COPY package.json .
RUN npm install -g [email protected]
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]
package.json文件是这样的:
"scripts": {
"start": "react-scripts start",
.
.
.
}
我删除了node_module并以这种方式尝试过,但是它不起作用,我做了很多这样的事情,但行不通。如果您能提供帮助,我会很高兴。
I have successfully created the image of the project. But when I want to run this image as a container, I get the following error
> [email protected] start
> react-scripts start
sh: react-scripts: not found
My docker file is like that :
FROM node:16.14-alpine3.14
WORKDIR /frontend
COPY package.json .
RUN npm install -g [email protected]
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]
The Package.json file is like that :
"scripts": {
"start": "react-scripts start",
.
.
.
}
I deleted node_module and tried it that way, but it didn't work, I did many things like this, but it doesn't work. I would be pleased if you could help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不是在package.json中安装依赖项。添加
运行npm install
这样You're not installing the dependencies from package.json. Add
RUN npm install
like this