简体   繁体   English

Docker:错误:找不到模块/app/src/myapp.js

[英]Docker: Error: Cannot find module /app/src/myapp.js

When I build my container it seems to compile without any issues using:当我构建我的容器时,它似乎可以使用以下方法进行编译而没有任何问题:

docker build -t mycompany:1.0.0 .

When I check docker images the container displays.当我检查docker images ,容器会显示。

When I try to host it locally using当我尝试使用本地托管它时

docker run -p 8081:8081 -it mycompany:1.0.0

it returns an error saying:它返回一个错误说:

Error: Cannot find module '/app/src/myapp.js

I feel like it shouldn't be this complicated.我觉得不应该这么复杂。 Here is my docker file:这是我的 docker 文件:

FROM node:10
WORKDIR /app/src
COPY package.json /app
RUN npm install
COPY . /app
CMD node myapp.js
EXPOSE 8081

What is off?什么是关闭?

You can see from the error itself , you are not copying anything inside /app/src.您可以从错误本身看到,您没有在 /app/src 中复制任何内容。 Your both COPY command's destination is /app.您的两个 COPY 命令的目的地都是 /app。 You need to place myapp.js inside /app/src.您需要将 myapp.js 放在 /app/src 中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 节点 myapp.js > myapp_error.log 2>&1 作为服务启动时等效 - node myapp.js > myapp_error.log 2>&1 equivalent when is starting as service docker ubuntu 中的 nodejs 找不到模块 /usr/src/app/index.js - nodejs in docker ubuntu cannot find module /usr/src/app/index.js 找不到在 docker 环境中运行的节点 js 应用程序的模块错误 - Cannot find module error for a node js app running in a docker environment 在 docker 容器上运行 nodejs 应用程序会给出“错误:找不到模块'/usr/src/app/nodemon'” - Running a nodejs app on a docker container gives “ Error: Cannot find module '/usr/src/app/nodemon' ” 错误:使用 docker-compose 时找不到模块“/usr/src/app/nodemon” - Error: Cannot find module '/usr/src/app/nodemon' while using docker-compose Docker 运行容器时出错 Error: Cannot find module '/home/app/server.js' - Docker error when running container Error: Cannot find module '/home/app/server.js' Docker NextJs ClientApp 的图像因错误无法找到模块“/app/server.js”而失败 - Docker Image for NextJs ClientApp failing with an error Cannot find module '/app/server.js' 错误 in./src/app.js 模块构建失败(来自./node_modules/babel-loader/lib/index.js):错误:找不到模块'@babel/preset-present-env' - ERROR in ./src/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module '@babel/preset-present-env' 找不到在 docker compose 环境中运行的节点 js 应用程序的模块 - Cannot find module for a node js app running in a docker compose environment 错误:找不到模块 '/next'、docker、next.js - Error: Cannot find module '/next', docker, next.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM