节点依赖性错误:ENOTEMPTY:目录不为空

时间:2020-10-10 13:33:07

标签: node.js npm dependencies npm-install

我对本地依赖项有疑问。我不知道该如何解决。

您可以查看所有步骤来重现我的错误。

有人有主意吗?非常感谢

复制步骤

$ npm i --prefix module-a
OK
$ npm i --prefix module-b
OK
$ npm i --prefix module-c
npm WARN tar ENOENT: no such file or directory, open 'module-c/node_modules/.staging/...'
npm WARN tar ENOENT: no such file or directory, open 'module-c/node_modules/.staging/...'
npm WARN tar ENOENT: no such file or directory, open 'module-c/node_modules/.staging/...'
...
npm ERR! code ENOTEMPTY
npm ERR! syscall rmdir
npm ERR! path module-c/node_modules/.staging/core-js-pure-7ef16f00
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rmdir 'module-c/node_modules/.staging/core-js-pure-7ef16f00'

环境

$ npm -v
6.14.6
$ node -v
v10.22.1

文件

module-a/package.json

{
   "name": "aaa",
   "main": "index.js"
}

module-b/package.json

{
   "name": "bbb",
   "main": "index.js",
   "dependencies": {
      "aaa": "file:../module-a"
   }
}

module-c/package.json

{
   "name": "ccc",
   "main": "index.js",
   "dependencies": {
      "aaa": "file:../module-a",
      "bbb": "file:../module-b"
   }
}

为您提供信息,我尝试使用npm link。此解决方案适用于我的开发环境,但不适用于其他环境,因为 build run 是在2台不同的服务器上执行的(所以 run 服务器的全局软件包中没有bbb软件包,并且出现错误Cannot find package bbb)。

module-c/package.json

{
   "name": "ccc",
   "main": "index.js",
   "script": {
      "postinstall": "cd ../module-b && npm link && cd - && npm link bbb"
   },
   "dependencies": {
      "aaa": "file:../module-a"
   }
}

0 个答案:

没有答案
相关问题