Node dependencies error: ENOTEMPTY: directory not empty

Viewed 747

I have a problem with local dependencies. I don't understand how to fix it.

You can see all steps to reproduce my error.

Someone have an idea ? Thank a lot

Steps to reproduce

$ 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'

Env

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

Files

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"
   }
}

For you information, I have try with npm link. This solution work on my dev env but it doesn't work on other environnements because build and run are executed on 2 differents servers (so run server doesn't have bbb package in global packages and I have the error 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 Answers
Related