npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.29k stars 3.04k forks source link

[BUG] npm ERR! Cannot read properties of null (reading 'package') #4787

Open arimus opened 2 years ago

arimus commented 2 years ago

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:

...
111 timing command:i Completed in 1071ms
112 verbose stack TypeError: Cannot read properties of null (reading 'package')
112 verbose stack     at Link.set root [as root] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:718:35)
112 verbose stack     at Link.replace (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1155:17)
112 verbose stack     at PlaceDep.replaceOldDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:426:17)
112 verbose stack     at PlaceDep.placeInTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:304:12)
112 verbose stack     at PlaceDep.place (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:214:10)
112 verbose stack     at new PlaceDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:71:10)
112 verbose stack     at /Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:31
112 verbose stack     at Array.map (<anonymous>)
112 verbose stack     at Arborist.[buildDepStep] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:8)
112 verbose stack     at async Arborist.buildIdealTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:216:7)
113 verbose cwd /Users/arimus/workspace/appbuilder-backend

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:

{
  "name": "project",
  "version": "1.0.0",
  "description": "",
  "license": "",
  "repository": {
    "url": "http://github.com:arimus/test.git"
  },
  "author": "arimus",
  "scripts": {
    "tsc": "tsc --project tsconfig.json",
    "start": "node ./dist/index.js",
  },
  "dependencies": {
    "apollo-server-hapi": "./apollo-server-hapi-3.5.1.tgz"
  }
}

Run

npm i

Error

...
111 timing command:i Completed in 1071ms
112 verbose stack TypeError: Cannot read properties of null (reading 'package')
112 verbose stack     at Link.set root [as root] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:718:35)
112 verbose stack     at Link.replace (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1155:17)
112 verbose stack     at PlaceDep.replaceOldDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:426:17)
112 verbose stack     at PlaceDep.placeInTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:304:12)
112 verbose stack     at PlaceDep.place (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:214:10)
112 verbose stack     at new PlaceDep (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:71:10)
112 verbose stack     at /Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:31
112 verbose stack     at Array.map (<anonymous>)
112 verbose stack     at Arborist.[buildDepStep] (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:984:8)
112 verbose stack     at async Arborist.buildIdealTree (/Users/arimus/.nvm/versions/node/v16.13.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:216:7)
113 verbose cwd /Users/arimus/workspace/appbuilder-backend

Environment

BobFrankston commented 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

silentcloud commented 2 years ago

+1 node 16.15.1 npm 8.11.0

lesliesu commented 2 years ago

+1 node 16.13.2 npm 8.1.2

AlekhyaYalla commented 2 years ago

Any update on this issue? I'm facing this issue

david-987 commented 2 years ago

+1 npm cache clear --force doesn't work which is my go-to when npm bugs out. npm 8.1.4 node 16.14

Zakyyy commented 2 years ago

same

jerinkalexander commented 2 years ago

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.

andrey-helldar commented 2 years ago

Node 16.16 and Npm 8.11 and 8.15 too

Show log ```bash 0 verbose cli C:\Users\Helldar\AppData\Local\nvs\default\node.exe C:\Users\Helldar\AppData\Local\nvs\default\node_modules\npm\bin\npm-cli.js 1 info using npm@8.11.0 2 info using node@v16.16.0 3 timing npm:load:whichnode Completed in 0ms 4 timing config:load:defaults Completed in 3ms 5 timing config:load:file:C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\npmrc Completed in 1ms 6 timing config:load:builtin Completed in 1ms 7 timing config:load:cli Completed in 1ms 8 timing config:load:env Completed in 0ms 9 timing config:load:file:D:\domains\volunteers\web\.npmrc Completed in 0ms 10 timing config:load:project Completed in 1ms 11 timing config:load:file:C:\Users\Helldar\.npmrc Completed in 0ms 12 timing config:load:user Completed in 0ms 13 timing config:load:file:C:\Users\Helldar\AppData\Local\nvs\default\etc\npmrc Completed in 1ms 14 timing config:load:global Completed in 1ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:credentials Completed in 0ms 17 timing config:load:setEnvs Completed in 1ms 18 timing config:load Completed in 9ms 19 timing npm:load:configload Completed in 9ms 20 timing npm:load:mkdirpcache Completed in 1ms 21 timing npm:load:mkdirplogs Completed in 0ms 22 verbose title npm i 23 verbose argv "i" 24 timing npm:load:setTitle Completed in 1ms 25 timing config:load:flatten Completed in 2ms 26 timing npm:load:display Completed in 3ms 27 verbose logfile logs-max:10 dir:C:\Users\Helldar\AppData\Local\npm-cache\_logs 28 verbose logfile C:\Users\Helldar\AppData\Local\npm-cache\_logs\2022-07-24T10_07_31_732Z-debug-0.log 29 timing npm:load:logFile Completed in 3ms 30 timing npm:load:timers Completed in 0ms 31 timing npm:load:configScope Completed in 0ms 32 timing npm:load Completed in 17ms 33 timing arborist:ctor Completed in 0ms 34 silly logfile start cleaning logs, removing 1 files 35 silly logfile done cleaning log files 36 timing arborist:ctor Completed in 0ms 37 timing idealTree:init Completed in 9ms 38 timing idealTree:userRequests Completed in 0ms 39 silly idealTree buildDeps 40 silly fetch manifest @cloudgeek/vue3-video-player@^0.3.10 41 http fetch GET 200 https://registry.npmjs.org/@cloudgeek%2fvue3-video-player 300ms (cache miss) 42 silly fetch manifest @mdi/font@^6.2.0 43 http fetch GET 200 https://registry.npmjs.org/@mdi%2ffont 128ms (cache miss) 44 silly fetch manifest apexcharts@^3.35.3 45 http fetch GET 200 https://registry.npmjs.org/apexcharts 64ms (cache miss) 46 silly fetch manifest axios@^0.27.2 47 http fetch GET 200 https://registry.npmjs.org/axios 45ms (cache miss) 48 silly fetch manifest laravel-vue-i18n@^2.1.1 49 http fetch GET 200 https://registry.npmjs.org/laravel-vue-i18n 47ms (cache miss) 50 silly fetch manifest laravel-mix@^6.0.43 51 http fetch GET 200 https://registry.npmjs.org/laravel-mix 57ms (cache miss) 52 silly fetch manifest postcss@^8.4.14 53 http fetch GET 200 https://registry.npmjs.org/postcss 43ms (cache miss) 54 silly fetch manifest lodash@^4.17.21 55 http fetch GET 200 https://registry.npmjs.org/lodash 58ms (cache miss) 56 silly fetch manifest maska@^1.5.0 57 http fetch GET 200 https://registry.npmjs.org/maska 39ms (cache miss) 58 silly fetch manifest moment@^2.29.3 59 http fetch GET 200 https://registry.npmjs.org/moment 51ms (cache miss) 60 silly fetch manifest moment-duration-format@^2.3.2 61 http fetch GET 200 https://registry.npmjs.org/moment-duration-format 54ms (cache miss) 62 silly fetch manifest moment-timezone@^0.5.34 63 http fetch GET 200 https://registry.npmjs.org/moment-timezone 58ms (cache miss) 64 silly fetch manifest pinia@^2.0.14 65 http fetch GET 200 https://registry.npmjs.org/pinia 51ms (cache miss) 66 silly fetch manifest @vue/composition-api@^1.4.0 67 http fetch GET 200 https://registry.npmjs.org/@vue%2fcomposition-api 152ms (cache miss) 68 silly fetch manifest vue@^3.2.25 69 http fetch GET 200 https://registry.npmjs.org/vue 69ms (cache miss) 70 silly fetch manifest vue@>= 2.5 < 2.7 71 silly fetch manifest typescript@^4.5.4 72 http fetch GET 200 https://registry.npmjs.org/typescript 142ms (cache miss) 73 silly fetch manifest pinia-plugin-persistedstate@^1.6.3 74 http fetch GET 200 https://registry.npmjs.org/pinia-plugin-persistedstate 45ms (cache miss) 75 silly fetch manifest query-string@^7.1.1 76 http fetch GET 200 https://registry.npmjs.org/query-string 41ms (cache miss) 77 silly fetch manifest roboto-fontface@* 78 http fetch GET 200 https://registry.npmjs.org/roboto-fontface 42ms (cache miss) 79 silly fetch manifest vue-router@^4.0.16 80 http fetch GET 200 https://registry.npmjs.org/vue-router 54ms (cache miss) 81 silly fetch manifest vue-toastification@^2.0.0-rc.5 82 http fetch GET 200 https://registry.npmjs.org/vue-toastification 47ms (cache miss) 83 silly fetch manifest vue3-apexcharts@^1.4.1 84 http fetch GET 200 https://registry.npmjs.org/vue3-apexcharts 42ms (cache miss) 85 silly fetch manifest vue3-audio-player@^1.0.5 86 http fetch GET 200 https://registry.npmjs.org/vue3-audio-player 42ms (cache miss) 87 silly fetch manifest vue3-openlayers@^0.1.68 88 http fetch GET 200 https://registry.npmjs.org/vue3-openlayers 48ms (cache miss) 89 silly fetch manifest vue3-telegram-login@^0.0.4 90 http fetch GET 200 https://registry.npmjs.org/vue3-telegram-login 48ms (cache miss) 91 silly fetch manifest vuetify@^3.0.0-beta.5 92 http fetch GET 200 https://registry.npmjs.org/vuetify 62ms (cache miss) 93 silly fetch manifest @formatjs/intl@^1.0.0 || ^2.0.0 94 http fetch GET 200 https://registry.npmjs.org/@formatjs%2fintl 157ms (cache miss) 95 silly fetch manifest vite-plugin-vuetify@^1.0.0-alpha.0 96 http fetch GET 200 https://registry.npmjs.org/vite-plugin-vuetify 62ms (cache miss) 97 silly fetch manifest vite-plugin-vuetify@1.0.0-alpha.12 98 silly fetch manifest vite@^2.9.9 99 http fetch GET 200 https://registry.npmjs.org/vite 75ms (cache miss) 100 silly fetch manifest less@* 101 http fetch GET 200 https://registry.npmjs.org/less 49ms (cache miss) 102 silly fetch manifest sass@^1.53.0 103 http fetch GET 200 https://registry.npmjs.org/sass 53ms (cache miss) 104 silly fetch manifest stylus@* 105 http fetch GET 200 https://registry.npmjs.org/stylus 57ms (cache miss) 106 silly fetch manifest vue-i18n@^9.0.0 107 http fetch GET 200 https://registry.npmjs.org/vue-i18n 54ms (cache miss) 108 silly fetch manifest webpack-plugin-vuetify@2.0.0-alpha.11 109 http fetch GET 200 https://registry.npmjs.org/webpack-plugin-vuetify 77ms (cache miss) 110 silly fetch manifest @vue/compiler-sfc@^3.2.6 111 http fetch GET 200 https://registry.npmjs.org/@vue%2fcompiler-sfc 74ms (cache miss) 112 silly fetch manifest webpack@^5.0.0 113 http fetch GET 200 https://registry.npmjs.org/webpack 124ms (cache miss) 114 silly fetch manifest webfontloader@^1.0.0 115 http fetch GET 200 https://registry.npmjs.org/webfontloader 49ms (cache miss) 116 silly fetch manifest @babel/core@^7.18.6 117 http fetch GET 200 https://registry.npmjs.org/@babel%2fcore 57ms (cache miss) 118 silly fetch manifest @babel/plugin-proposal-class-properties@^7.18.6 119 http fetch GET 200 https://registry.npmjs.org/@babel%2fplugin-proposal-class-properties 52ms (cache miss) 120 silly fetch manifest @babel/plugin-proposal-optional-chaining@^7.18.6 121 http fetch GET 200 https://registry.npmjs.org/@babel%2fplugin-proposal-optional-chaining 58ms (cache miss) 122 silly fetch manifest @popperjs/core@^2.11.5 123 http fetch GET 200 https://registry.npmjs.org/@popperjs%2fcore 89ms (cache miss) 124 silly fetch manifest @types/lodash@^4.14.182 125 http fetch GET 200 https://registry.npmjs.org/@types%2flodash 63ms (cache miss) 126 silly fetch manifest @types/node@^18.0.5 127 http fetch GET 200 https://registry.npmjs.org/@types%2fnode 69ms (cache miss) 128 silly fetch manifest @types/webfontloader@^1.0.0 129 http fetch GET 200 https://registry.npmjs.org/@types%2fwebfontloader 66ms (cache miss) 130 silly fetch manifest @vitejs/plugin-vue@^2.3.3 131 http fetch GET 200 https://registry.npmjs.org/@vitejs%2fplugin-vue 89ms (cache miss) 132 silly fetch manifest autoprefixer@^10.4.7 133 http fetch GET 200 https://registry.npmjs.org/autoprefixer 56ms (cache miss) 134 silly fetch manifest eslint@^8.18.0 135 http fetch GET 200 https://registry.npmjs.org/eslint 48ms (cache miss) 136 silly fetch manifest eslint-plugin-prettier@^4.2.1 137 http fetch GET 200 https://registry.npmjs.org/eslint-plugin-prettier 59ms (cache miss) 138 silly fetch manifest prettier@>=2.0.0 139 http fetch GET 200 https://registry.npmjs.org/prettier 63ms (cache miss) 140 silly fetch manifest eslint-plugin-you-dont-need-lodash-underscore@^6.12.0 141 http fetch GET 200 https://registry.npmjs.org/eslint-plugin-you-dont-need-lodash-underscore 45ms (cache miss) 142 silly fetch manifest postcss-import@^14.1.0 143 http fetch GET 200 https://registry.npmjs.org/postcss-import 42ms (cache miss) 144 silly fetch manifest vite@^2.7.0 145 silly fetch manifest sass@* 146 silly fetch manifest vuetify@^3.0.0-beta.4 147 silly fetch manifest typescript@^4.5 148 silly fetch manifest vue@^3.2.0 149 timing idealTree Completed in 3734ms 150 timing command:i Completed in 3743ms 151 verbose stack TypeError: Cannot read properties of null (reading 'explain') 151 verbose stack at Arborist.[explainPeerConflict] (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1434:29) 151 verbose stack at Arborist.[failPeerConflict] (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1427:44) 151 verbose stack at Arborist.[loadPeerSet] (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1394:34) 151 verbose stack at async Arborist.[buildDepStep] (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:976:11) 151 verbose stack at async Arborist.buildIdealTree (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:218:7) 151 verbose stack at async Promise.all (index 1) 151 verbose stack at async Arborist.reify (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:153:5) 151 verbose stack at async Install.exec (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\lib\commands\install.js:156:5) 151 verbose stack at async module.exports (C:\Users\Helldar\AppData\Local\nvs\node\16.16.0\x64\node_modules\npm\lib\cli.js:78:5) 152 verbose cwd D:\domains\volunteers\web 153 verbose Windows_NT 10.0.22000 154 verbose node v16.16.0 155 verbose npm v8.11.0 156 error Cannot read properties of null (reading 'explain') 157 verbose exit 1 158 timing npm Completed in 3831ms 159 verbose unfinished npm timer reify 1658657251816 160 verbose unfinished npm timer reify:loadTrees 1658657251822 161 verbose unfinished npm timer idealTree:buildDeps 1658657251833 162 verbose unfinished npm timer idealTree:#root 1658657251833 163 verbose code 1 164 error A complete log of this run can be found in: 164 error C:\Users\Helldar\AppData\Local\npm-cache\_logs\2022-07-24T10_07_31_732Z-debug-0.log ```
arimus commented 2 years ago

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.

ajibadeabd commented 2 years ago

downgrade your node to 16.0, npm to 7+. this workes for me

AnatuGreen commented 2 years ago

Mine is this error:

npm ERR! Cannot read properties of null (reading 'children')

I have even uninstalled Node and reinstalled it. Same issue

Zakyyy commented 2 years ago

@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

AnatuGreen commented 2 years ago

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: @.***>

BobFrankston commented 2 years ago

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.

Tauqeer180 commented 2 years ago

none of above Works

ZackryPaul commented 2 years ago

I have to install everything with --legacy-peer-deps

AntreasPetsas commented 1 year ago

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.

zanemcca commented 1 year ago

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.

heyakyra commented 1 year ago

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

FlorianDevPhynix commented 1 year ago

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

onorigin commented 1 year ago

Same as above but 9.2.0 did not resolve it

avidj commented 1 year ago

I get this when using npm workspaces. npm 8.19.3 node 18.3.0

jmni-cn commented 1 year ago

上面的办法我都试了,可还是不能解决这个问题

heyakyra commented 1 year ago

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

StrixSC commented 1 year ago

Deleting node_modules/ worked for me.

donworld commented 1 year ago

+1 node 16.14.1 npm 8.19.2

downgrade npm to 8.1.0 worked for me

CodyKlimkofski commented 1 year ago

+1 node 16.19.1 npm 9.4.2

fifkapetr commented 1 year ago

+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

KCmean commented 1 year ago

even I am having the same error while installing styled components. I tried downloading the version too, but it didn't help.

manikanda-s commented 1 year ago

try this --> npm install styled-components@5.3.10

it works :-)

hanleymark commented 1 year ago

npm install styled-components@latest <--- worked for me

vaesonshu commented 1 year ago

I tried delete package-lock.json and npm install again, Solved my problem.

mhadad commented 1 year ago

npm install styled-components@latest

it should be npm install -g styled-components@latest

kashif-ghafoor commented 11 months ago

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.

trusktr commented 10 months ago

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.

trusktr commented 10 months ago

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.

BobFrankston commented 8 months ago

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

mwe commented 6 months ago

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

boshoff commented 2 weeks ago

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.