So I’ve been through many, many reports of this bug, but it seems there is a core issue here that is related to dependencies that are included via local includes in the package.json, e.g. “my-module”: “file:…/my-module”
My environment is as follows:
Node - 8.12.0
npm - 6.4.1
OS: Ubuntu 16.04 LTS
At one point, removing node_modules and package-lock.json was working.
As I added more file:…/my-module type dependencies, just removing node_modules and package-lock.json stopped working, what did work was running “npm install” multiple times. It would fail with the above error, then running it again would work. As I added more local dependencies, I had to run “npm install” 3 times.
At this point it has stopped working completely. There are two ways I can get this to work.
If I downgrade npm to 3.10.10 I can remove node_modules, then “npm install” works. The problem is that I have another module that will not build properly w/ npm 3.10.10, but it works fine w/ npm 6.4.1
The other way I can get this to work is to change into my main package folder, then run npm install, manually, for each of the modules included in my package.json file. e.g.
npm install …/my-module1
npm install …/my-module2
npm install …/my-module3
After I do the above, I can cd my_main_node_server_package then:
rm -rf node_modules
The above works every time.
The thing I noticed is that w/ 3.10.10 copies all of the modules needed to my my_main_node_server_package/node_modules directory, for example, if my-module-1 had aws-sdk in it’s package.json, then aws-sdk gets copied into my_main_node_server_package/node_modules/aws-sdk.
If I use 6.4.1 it copies aws-sdk to my-module-1/node_modules/aws-sdk, then it symlinks my-module-1 into my_main_node_server_package/node_modules/my-module-1.
When using 6.4.1 I cannot get npm install to work with a clean tree. I must either use email@example.com or I must change into the directory where the main package lives, then type npm install <each_dependent_package>.
Removing package-lock.json does not help.
I’ve seen quite a few reports of this issue, with quite a few workaround, but no fixes. I’d be happy to try something new, pre-release, do some additional testing, provide logs, or whatever is needed to resolve this once and for all. I’m sure you npm devs are tired of hearing about this one, and I’m happy to do whatever I can to help get this resolved. Just to recap:
- I believe this is directly related to using local requirements in package.json .e.g. “foo”: “file:…/foo”
- The problem does not exhibit itself when using firstname.lastname@example.org (although there are other issues with other projects I have on the email@example.com release).
- Running “npm install” multiple times throws different errors, in some cases (pointing to a race condition)
If anoyone has a fix, or a better workaround, or needs to ask questions, I am all ears :)