[BUG] Running `npm i` fails with Cannot read properties of null (reading 'isDescendantOf')
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
When installing a project using PNPM first and then subsequently using standard npm to install it, the install process borks after a long time with:
npm ERR! Cannot read properties of null (reading 'isDescendantOf')
Looking at the generated debug log one can see a null pointer being mentioned:
Adding a console.log("link.target is null!", link) just before it fails shows this:

This points at one of the PNPM installed files being an issue of some sort. Maybe due to the symlinks created?

Expected Behavior
I would expect that NPM would go about its business and handle the situation where PNPM previously has stepped all over its turf gracefully 😄
It took some attempts (actually writing this) to discover that wiping with rm -r node_modules would fix the issue, so maybe one could add some heuristics to detect weird symlinks where there should not be and just delete the directory before re-installing? That would be very user friendly, at least.
Steps To Reproduce
hub clone fatso83/example-encrypt-properties(clone this repo)cd example-encrypt-properties && pnpm i && npm i- Observe an error:
npm ERR! Cannot read properties of null (reading 'isDescendantOf')
Environment
- npm: 7.12.0 (also tested on v6)
- Node.js: 18.10.0 (latest, also tested on v16)
- OS Name: Ubuntu 22.04.1 LTS
- System Model Name: ?
- npm config:
; "user" config from /home/carlerik/.npmrc
//registry.npmjs.org/:_authToken = (protected)
flex-sdk:npm_cmd_ran = "install"
; node bin location = /usr/local/bin/node
; node version = v18.10.0
; npm local prefix = /home/carlerik/code/nimble
; npm version = 8.19.2
; cwd = /home/carlerik/code/nimble
; HOME = /home/carlerik
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce with pnpm i followed by npm i in fatso83/example-encrypt-properties, then inspect @npmcli/arborist/lib/arborist/build-ideal-tree.js around resolveLinks, where the stack trace reports the null access. Done means npm handles the PNPM-created layout without the isDescendantOf error; verify by repeating the reported steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100