简体   繁体   English

docker-compose:无法将本地模块添加到项目中,找不到 package.json 文件

[英]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

  1. What would block it from seeing the package.json file, if it is there?什么会阻止它看到 package.json 文件(如果存在)?
  2. What would I need to do to make this work as local modules definitely make sense in this case but are not playing well with docker?我需要做什么才能使这项工作正常进行,因为本地模块在这种情况下绝对有意义,但不能很好地与 docker 配合使用?

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.

相关问题 docker-compose 对于节点项目获取找不到 package.json on windows - docker-compose for a node project getting cannot find package.json on windows 在 docker-compose 期间找不到模块 @angular-devkit/build-angular/package.json - Cannot find module @angular-devkit/build-angular/package.json during docker-compose up docker-compose 与卷 - package.json 的“没有这样的文件或目录” - docker-compose up with volumes - “no such file or directory” for package.json npm ENOENT:没有这样的文件或目录,打开“/usr/app/package.json”。 在尝试使用 docker-compose 与 docker 共享本地空间时 - npm ENOENT: no such file or directory, open '/usr/app/package.json'. While trying to share local space with docker using docker-compose Docker-compose up:没有这样的文件或目录,打开'/usr/src/app/package.json' - Docker-compose up : no such file or directory, open '/usr/src/app/package.json' docker-compose:找不到模块“typeorm” - docker-compose: Cannot find module 'typeorm' Docker找不到package.json - Docker cannot find package.json 错误:找不到模块“../../package.json” - Error: Cannot find module '../../package.json' 电子找不到模块 package.json - electron cannot find module package.json Docker compose 在路径中找不到 package.json - Docker compose cant find package.json in path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM