Open arimus opened 2 years ago
This is frustrating because I can look at the log and find out the call stack, but it doesn't help me in fixing the problem. I accept that it's my error, but it would save many hours if there were more information about the source of the error.
In my case, I get Cannot read properties of null (reading 'package')
. I'm using symbolic links, so there may be an inconsistency, but how can I find it? I can attach the log though I'm wary about posting specific info.
The line
37 verbose shrinkwrap failed to load node_modules/.package-lock.json missing from lockfile: ../mlib/node_modules/ansi-styles
hints at the problem but it works in other contexts
+1 node 16.15.1 npm 8.11.0
+1 node 16.13.2 npm 8.1.2
Any update on this issue? I'm facing this issue
+1 npm cache clear --force
doesn't work which is my go-to when npm bugs out.
npm 8.1.4
node 16.14
same
128 verbose node v16.15.1 129 verbose npm v8.14.0 130 error Cannot read properties of null (reading 'children') 131 verbose exit 1
Same here while running npm link.
Node 16.16 and Npm 8.11 and 8.15 too
This problem is super frustrating. I'm trying to get the package updated upstream, so that I no longer have a local file dependency, but that is taking a long time as well. Kind of surprised that more folks haven't been having this issue, which would give it more attention.
Worth noting that I've been playing with pnpm recently, which does not have this issue and also has a lot of good features. However, I did find some local relative path dependencies inside my tarball dep. That forced me to adjust to regular npm repo deps and rebuild the tarball, but that was pretty easy. Generally speaking, I'd love to just use npm straight up, but I may bite the bullet and start using pnpm (with shamefully-hoist :P for the time being).
Happy to re-test this when things are fixed though.
downgrade your node to 16.0, npm to 7+. this workes for me
Mine is this error:
npm ERR! Cannot read properties of null (reading 'children')
I have even uninstalled Node and reinstalled it. Same issue
@AnatuGreen Can you try to install the dependencies from a terminal that opened with Rosetta (if you're using MacBook with M1 chip) use node v16.16.0 npm v8
I downgraded NPM to version 7 and the error stopped.
On Mon, 15 Aug 2022, 10:27 am Ahmed Zaki, @.***> wrote:
@AnatuGreen https://github.com/AnatuGreen Can you try to install the dependencies from a terminal that opened with Rosetta use node v16.16.0 npm v8
— Reply to this email directly, view it on GitHub https://github.com/npm/cli/issues/4787#issuecomment-1214813419, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWW3LQHW3O663THHU6VQXWTVZIEPTANCNFSM5T537F3A . You are receiving this because you were mentioned.Message ID: @.***>
As an FYI, my workaround is to delete or rename node_modules and then let npm install recreate it. I suspect problems in handling symlinks on Windows.
none of above Works
I have to install everything with --legacy-peer-deps
downgrade to npm@7.0 fixed the issue. Just for the records I was using v8.19.2. also worked by downgrading to 8.1.0.
For those who have not found any of the previously mentioned solutions useful I found that adding a console.log(node)
directly before the broken line at ...node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:718
to be very useful for debugging what was happening.
In my case I had a npm linked package in the package-lock that should have referenced the npm deployment of that dependency instead.
Same here while running npm link
This happens if I use npm link
with the package location on disk as a shortcut for cd [package-location]; npm link; cd [dependent project]; npm link [package-name]
If I instead link the package names, building my dependent project gives errors like Module not found: Error: Can't resolve '[package-name]/[module-name]' in '[dependent-project]'
Node v16.18.1 npm 9.1.2
I was having the similar issue npm ERR! Cannot read properties of null (reading 'name')
my npm version was 8.19.2
upgrading to latest version, which was 9.2.0 at the time I was writing this, resolved this issue
Same as above but 9.2.0 did not resolve it
I get this when using npm workspaces. npm 8.19.3 node 18.3.0
上面的办法我都试了,可还是不能解决这个问题
If I instead link the package names, building my dependent project gives errors like
Module not found: Error: Can't resolve '[package-name]/[module-name]' in '[dependent-project]'
Node v16.18.1 npm 9.1.2
I have upgraded to Node v18.13.0 and npm 9.3.1 but still hit this issue
I no longer get a different error when symlinking the directory like npm link ../relative/path/to/package
and instead get the same error as using the standard npm link; cd ../project; npm link package-name
commands.
I have to install everything with --legacy-peer-deps
This had no effect
Deleting node_modules/
worked for me.
+1 node 16.14.1 npm 8.19.2
downgrade npm to 8.1.0 worked for me
+1 node 16.19.1 npm 9.4.2
+1 node v18.16.0 npm 9.6.6
Prompt: npm install styled-components ERR:
01-starting-project 2 git:(accounts) ✗ npm install styled-components
npm ERR! Cannot read properties of null (reading 'edgesOut')
npm ERR! A complete log of this run can be found in: /Users/petrfifka/.npm/_logs/2023-05-09T11_02_05_183Z-debug-0.log
2023-05-09T11_02_05_183Z-debug-0.log
EDIT: downgrade to 8.1.0 didn't work. I needed to downgrade to 7.7.6
even I am having the same error while installing styled components. I tried downloading the version too, but it didn't help.
try this --> npm install styled-components@5.3.10
it works :-)
npm install styled-components@latest <--- worked for me
I tried delete package-lock.json and npm install again, Solved my problem.
npm install styled-components@latest
it should be npm install -g styled-components@latest
I encountered this error when using npm link
, and I'd like to share the solution that worked for me.
Solution: The error arises when running npm link multiple times.
When you initially run npm link
in the root folder of your project, it creates a symbolic link in the global packages. You can check the global packages using npm ls -g.
If you need to run npm link
again, you may encounter this error. To resolve it, follow these steps:
a. First, you should unlink the package using npm unlink <package-name>
.
b. After unlinking, you can run npm link
again without any issues.
I just encountered this issue with npm 10.1.0. I didn't try downgrading to 9.0.
This is the error
60 verbose stack TypeError: Cannot read properties of null (reading 'package')
60 verbose stack at set root [as root] (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:746:35)
60 verbose stack at set root [as root] (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:812:20)
60 verbose stack at set root [as root] (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:820:19)
60 verbose stack at set root [as root] (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:812:20)
60 verbose stack at Node.replace (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1173:26)
60 verbose stack at PlaceDep.replaceOldDep (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:387:17)
60 verbose stack at new PlaceDep (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:256:12)
60 verbose stack at #buildDepStep (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:933:18)
60 verbose stack at async Arborist.buildIdealTree (/Users/trusktr/.npm-packages/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:196:7)
60 verbose stack at async Promise.all (index 1)
In my case, I deleted node_modules
and then tried what I was previously trying, and it worked.
I'm also using Lerna, but I haven't had this issue before. Many people above said this has to do with linked dependencies, and Lerna is in fact linking dependencies from all of my git submodules together. So it seems that linking might have to do with the issue.
In a project that's a git submodule and workspace in a parent repo, I had to delete node_modules
and run npm install --no-workspaces
for the install to succeed.
I'm guessing this means that running plain npm install
in the git submodule traverses upward, and interacts with workspaces outside of the project, and these workspaces have been linked with yarn
.
This is painful. Really hoping this can be fixed.
This is still happening in Windows but not DSL. How can I trace it down? The problem shows up long after the root cause making it hard for me to trace the problem back.
npm versions Windows 10.2.0 WSL 10.2.4
I just encountered this issue with npm 10.1.0. I didn't try downgrading to 9.0.
This is the error
60 verbose stack TypeError: Cannot read properties of null (reading 'package') In my case, I deleted `node_modules` and then tried what I was previously trying, and it worked.
If this does not resolve it, also deleting the package.lock.json resolves it, it seems also to be related by a package.lock.json that is not matching the current dependency tree in relation with symlinks
Node.js: 20.12.1 npm: 10.8.2 OS: macOS 14.6
$ npm cache clean --force
(output omitted)
$ rm -rf node_modules
$ rm package-lock.json
$ npm i
npm error Cannot read properties of null (reading 'package')
No luck, much easier to switch to pnpm.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
I do an initial npm install, which works fine. Subsequent runs result in the error:
Expected Behavior
npm install not failing with the above error.
Steps To Reproduce
Environment Starting with NPM v8.6.0 (8.5.5 does not have this issue)
Config A package.json with a tgz file dependency. Example:
Run
npm i
Error
Environment