[英]docker-compose: cannot add local module to project, canno find package.json file
I have two projects, let's say, projectA and projectB.我有两个项目,比方说,projectA 和 projectB。 The folder heirarchy looks like the following:文件夹层次结构如下所示:
projects
- banking
- accounts
- projectA
- loans
- projectB
I added projectA to projectB as a local module using npm install and this worked as I was able to access the code.我使用 npm install 将 projectA 作为本地模块添加到 projectB 中,这在我能够访问代码时起作用。 However, when I tried to push projectB to the docker server using docker-compose running through WebStorm I am receiving an error:但是,当我尝试使用通过 WebStorm 运行的 docker-compose 将 projectB 推送到 docker 服务器时,我收到一个错误:
npm ERR! npm 错误! code ENOLOCAL编码 ENOLOCAL
npm ERR. npm 错误。 Could not install from "../../accounts/projectA" as it does not contain a package.json file.无法从“../../accounts/projectA”安装,因为它不包含 package.json 文件。
This is strange as this folder definitely contains a package.json file.这很奇怪,因为这个文件夹肯定包含一个 package.json 文件。 Also, it seems to fail when it tries to run this command line此外,它似乎在尝试运行此命令行时失败
RUN cd /home/parent && npm install --production运行 cd /home/parent && npm install --production
when you execute a docker build you send all the current directory to docker (its called context).当您执行 docker 构建时,您将所有当前目录发送到 docker(它称为上下文)。 then it starts building things.然后它开始构建东西。
it means that docker only has access to a particular folder (usually the current folder)这意味着 docker 只能访问特定文件夹(通常是当前文件夹)
../ is therefore out of it ../ 因此不在其中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.