npm / cli

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

[BUG] Cannot read properties of undefined (reading 'isStream') #6665

Closed oliverfindl closed 1 year ago

oliverfindl commented 1 year ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

$ npm i
npm ERR! Cannot read properties of undefined (reading 'isStream')

npm ERR! A complete log of this run can be found in: /home/$USER/.npm/_logs/2023-07-21T12_24_41_712Z-debug-0.log

Relevant part from log:

171 verbose stack TypeError: Cannot read properties of undefined (reading 'isStream')
171 verbose stack     at new Body (/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:43:18)
171 verbose stack     at new Request (/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/request.js:51:5)
171 verbose stack     at makeFetchHappen (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/lib/index.js:9:19)
171 verbose stack     at doFetch (/usr/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/index.js:108:15)
171 verbose stack     at async RegistryFetcher.packument (/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:87:19)
171 verbose stack     at async RegistryFetcher.manifest (/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:118:23)
172 verbose cwd $PATH_TO_PROJECT
173 verbose Linux 6.2.6-76060206-generic
174 verbose node v20.5.0
175 verbose npm  v9.8.0
176 error Cannot read properties of undefined (reading 'isStream')
177 verbose exit 1
178 timing npm Completed in 197ms

Expected Behavior

Successfully install dependencies.

Steps To Reproduce

  1. Open your project
  2. Delete node_modules and package-lock.json
  3. Run npm i
  4. See error

Environment

oliverfindl commented 1 year ago

Might be related to latest system updates:

Start-Date: 2023-07-20  15:30:35
Commandline: packagekit role='update-packages'
Requested-By: $USER (1000)
Upgrade: libcurl4-openssl-dev:amd64 (7.81.0-1ubuntu1.10, 7.81.0-1ubuntu1.13), libcurl4:amd64 (7.81.0-1ubuntu1.10, 7.81.0-1ubuntu1.13), libcurl3-gnutls:amd64 (7.81.0-1ubuntu1.10, 7.81.0-1ubuntu1.13), python3-samba:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), google-chrome-stable:amd64 (114.0.5735.198-1, 115.0.5790.98-1), samba-vfs-modules:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), samba:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), libwbclient0:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), libsmbclient:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), samba-dsdb-modules:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), samba-common-bin:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), nodejs:amd64 (18.16.1-deb-1nodesource1, 18.17.0-deb-1nodesource1), linux-firmware:amd64 (20230629.gitee91452d-0ubuntu1+system76~1688393113~22.04~870dac4, 20230629.gitee91452d-0ubuntu1+system76~1689594960~22.04~9d563bf), smbclient:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), samba-libs:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), samba-common:amd64 (2:4.15.13+dfsg-0ubuntu1.1, 2:4.15.13+dfsg-0ubuntu1.2), curl:amd64 (7.81.0-1ubuntu1.10, 7.81.0-1ubuntu1.13)
End-Date: 2023-07-20  15:32:53

Start-Date: 2023-07-21  13:58:27
Commandline: apt-get upgrade
Requested-By: $USER (1000)
Upgrade: google-chrome-stable:amd64 (115.0.5790.98-1, 115.0.5790.102-1)
End-Date: 2023-07-21  13:58:32

Start-Date: 2023-07-21  14:02:42
Commandline: apt-get install -y nodejs
Requested-By: $USER (1000)
Upgrade: nodejs:amd64 (18.17.0-deb-1nodesource1, 20.5.0-deb-1nodesource1)
End-Date: 2023-07-21  14:02:45

Update from nodejs@18.17.0 to nodejs@20.5.0 did not solve my issue.

oliverfindl commented 1 year ago

I just found out, that latest working version of nodejs in my environment is 18.16.1.

ljharb commented 1 year ago

Don’t install node from apt.

Can you keep node the same, and try installing different versions of npm until you figure out which one breaks?

oliverfindl commented 1 year ago

Hello @ljharb,

just got it working with latest nodejs@20.5.0 and npm@9.8.1. Even if I install node@18.17.0 and npm@9.6.7 (first combination, that broke it for me) or nodejs@20.5.0 and npm@9.8.0 (as per my original report in this issue), both are now working as expected. Honestly, I don't know what went wrong here. I just did regular system update yesterday and it broke...

Feel free to close this issue.

Thanks.

ljharb commented 1 year ago

The node version shouldn’t make a difference, only the npm version.