Open fatso83 opened 1 year ago
Theoretically, links shouldn't be an issue. This is worth fixing.
I'm also having this issue. In a workspace I have to run npm run version --no-workspaces ...
to avoid the error. Other workspaces outside of the workspace where I'm running npm version
are linked together using yarn install
.
I also have a similar problem when not using --no-workspaces
with this error for npm install
:
@fritzy this isn't only about links. I have no links in node_modules
of the project with this error, but the project is simply a workspace (a git submodule in a super repo).
getting a similar error trying to run npm dedupe
in https://github.com/open-telemetry/opentelemetry-js-contrib - npm install
completes just fine.
6004 verbose stack TypeError: Cannot read properties of null (reading 'isDescendantOf')
6004 verbose stack at #resolveLinks (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1414:37)
6004 verbose stack at #buildDepStep (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:783:32)
6004 verbose stack at #buildDepStep (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1035:30)
6004 verbose stack at async Arborist.buildIdealTree (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:196:7)
6004 verbose stack at async Promise.all (index 1)
6004 verbose stack at async Arborist.reify (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
6004 verbose stack at async Dedupe.exec (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/lib/commands/dedupe.js:47:5)
6004 verbose stack at async module.exports (/Users/simen/.nvm/versions/node/v20.10.0/lib/node_modules/npm/lib/cli-entry.js:61:5)
6005 verbose cwd /Users/simen/repos/opentelemetry-js-contrib
6006 verbose Darwin 23.2.0
6007 verbose node v20.10.0
6008 verbose npm v10.2.5
6009 error Cannot read properties of null (reading 'isDescendantOf')
This seems to occur when running npm i
outside a directory with an existing package.json
. Others may wish to check if they're actually in the directory they think they are. The error message is still poor though.
@mikemaccana when i run npm in a dir that doesn't have a package.json file, i get a pretty clear ENOENT error about a missing package.json. (when it's not valid JSON, i get a clear EJSONPARSE error)
Is there an existing issue for this?
This issue exists in the latest npm version
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: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 :smile:
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
npm ERR! Cannot read properties of null (reading 'isDescendantOf')
Environment
//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.