This NPM error happens when used in a monorepo with NPM workspaces feature. I have a monorepo with 5 packages: a, b, c, d and e. I also have a package in a different repository which is not a workspace. The name of that package is x and it depends on package c and d.
The problem happens when I try to add package x as a dependency for my package e. Every time I try: npm install x -w packages/e, I get following error:
npm ERR! Cannot set properties of null (setting 'parent')
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/harshal/.npm/_logs/2022-11-11T17_27_57_008Z-debug-0.log
There is absolutely nothing in the error log except the fact that the error originates in arborist package when resolving dependencies.
I have tried using multiple NPM versions ^8.x.x but it doesn't seem to resolve it.
I've seen this happen when you're trying to run npm i from the wrong location.
Just double check that you are actually running at the same location your package.json file is located.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With