Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 [BUG] npm@7 is broken on node@8 or older #2599

Closed
jcuna opened this issue Feb 2, 2021 · 25 comments
Closed

🐞 [BUG] npm@7 is broken on node@8 or older #2599

jcuna opened this issue Feb 2, 2021 · 25 comments
Assignees
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@jcuna
Copy link

jcuna commented Feb 2, 2021

Current Behavior:

Running npm install -g npm@7.5.1
Running npm install -g npm on version 7.5.2

produces the following output.


TypeError: Cannot destructure property `stat` of 'undefined' or 'null'.
--
92 | at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/node-gyp/lib/index.js:2:29)
93 | at Module._compile (module.js:652:30)
94 | at Object.Module._extensions..js (module.js:663:10)
95 | at Module.load (module.js:565:32)
96 | at tryModuleLoad (module.js:505:12)
97 | at Function.Module._load (module.js:497:3)
98 | at Module.require (module.js:596:17)
99 | at require (internal/module.js:11:18)
100 | at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js:4:55)
101 | at Module._compile (module.js:652:30)
102 | /usr/local/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:163
103 | throw new Error('call config.load() before reading values')
104 | ^
105 |  
106 | Error: call config.load() before reading values
107 | at Config.get (/usr/local/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:163:13)
108 | at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:171:32)
109 | at emitOne (events.js:116:13)
110 | at process.emit (events.js:211:7)
111 | at process._fatalException (bootstrap_node.js:375:26)

Expected Behavior:

Packages installed successfully

Steps To Reproduce:

ex. steps to reproduce the behavior:

  1. aws/codebuild/nodejs:8.11.0
  2. With this config...
  3. Run '...'
  4. See error...

Environment:

  • OS: Amazon Linux 2 | aws/codebuild/amazonlinux2-aarch64-standard:1.0
  • Node: 8.11.0
  • npm: 7.5.1 and 7.5.2
@jcuna jcuna added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Feb 2, 2021
@wraithgar
Copy link
Member

wraithgar commented Feb 3, 2021

If you are still running node 8 you are going to want to use npm v6, You can use the latest-6 tag to install the latest version of 6.

$ npm install npm@latest-6

If you have installed npm 7 on node 8 you can run this command to get back to a working npm 6

$ curl -qs https://www.npmjs.com/install.sh|npm_install=6.14.11 sh

@joshuasaunders
Copy link

Running into the exact same issue and installing latest version of 6 isn't working for me with node 8. When I run npm install npm@latest-6 or npm install -g npm@latest-6 I still get the same error TypeError: Cannot destructure property 'stat' of 'undefined' or 'null'. Any ideas?

@ljharb
Copy link
Contributor

ljharb commented Feb 3, 2021

If you're using nvm, you can also nvm install-latest-npm, and you'll always be guaranteed to get the latest working version (but you have to start with a working node/npm, ofc)

@tuchidoghostmaster
Copy link

Hi all,

I have the same error,

I deployed from Gitlab to Heroku and had the same error,

Is there a way to fix it?

image

@slavoroi
Copy link

slavoroi commented Feb 3, 2021

We have the same issue in our Jenkins pipilines.
Running npm i -g npm installs npm 7.5.2 when i'm on node 8.
It also breaks our usage of nvm in our local computers (nvm 33).
Also I tried using npm 7 and it failed on many libraries, like rollup and many more!
Didn't you promise npm 7 would be for node 15+, no?

@eAi
Copy link

eAi commented Feb 3, 2021

I'm also having this error when I upgraded from 5.6.0 to 7.5.2. Reinstalling node from nodejs.org (with npm 6.14.10) fixed this.

@guilhermesad
Copy link

Getting same error trying to deploy to Heroku:
Screen Shot 2021-02-03 at 10 51 38 AM

@ljharb
Copy link
Contributor

ljharb commented Feb 3, 2021

@slavoroi #2599 (comment)

@joshuasaunders
Copy link

I am really stuck here and this is on my production server. I can't get nvm installed, get the same error installing nvm TypeError: Cannot destructure property stat of 'undefined' or 'null'. I can't figure out a way to upgrade node, and npm isn't working for anything. Can't even tpye npm -v without the error. I don't want to uninstall npm completely to reinstall it, as that may take down my production server in the process. Anyone have any other ideas to fix this problem?

@tekstrand
Copy link

We're seeing this issue in our pipeline. As far as I can tell downgrading to npm 6 does fix it, but that is quite a pain.

@joshuasaunders
Copy link

Yeah, thanks. Had to manually do the install of lower version of npm. Then upgrade node. Then was able to update npm.

sykesm added a commit to sykesm/fabric that referenced this issue Feb 3, 2021
See npm/cli#2599

Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
@wraithgar wraithgar self-assigned this Feb 3, 2021
@wraithgar
Copy link
Member

If you have installed npm 7 on node 8 you can run this command to get back to a working npm 6

$ curl -s https://www.npmjs.com/install.sh|npm_install=6.14.11 sh

@zenigate
Copy link

zenigate commented Feb 3, 2021

If you have installed npm 7 on node 8 you can run this command to get back to a working npm 6

$ curl -s https://www.npmjs.com/install.sh|npm_install=6.14.11 sh

Thank you, This help me fix this issue

@wraithgar wraithgar changed the title [BUG] Cannot destructure property stat of 'undefined' or 'null'. [BUG] npm is broken after updating to npm@7 when using node 8 Feb 3, 2021
@ljharb
Copy link
Contributor

ljharb commented Feb 3, 2021

@wraithgar heads up that that's not working for me; curl doesn't output anything to the pipe unless i add -o-, and inside the script, the curl to get the tarball URL has the same problem.

@wraithgar
Copy link
Member

@ljharb that sounds like a curl version issue maybe? If I remember correctly older versions of curl didn't automatically handle being piped correctly.

The readme example has -L as a parameter but that's only for following redirects, of which there aren't any on that url.

What version of curl were you using? I am on curl 7.64.1

@ljharb
Copy link
Contributor

ljharb commented Feb 3, 2021

@wraithgar i'm using whatever curl comes with Mac OS Big Sur, which is indeed v7.64.1. Do you perhaps have a ~/.curlrc that is altering how curl behaves?

lindluni pushed a commit to hyperledger/fabric that referenced this issue Feb 3, 2021
See npm/cli#2599

Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
@wraithgar
Copy link
Member

wraithgar commented Feb 3, 2021

Nope, no curlrc, and same version but I'm not on Big Sur, still on Catalina.

@nlf
Copy link
Contributor

nlf commented Feb 3, 2021

I just tried on Big Sur in both fish and the default zsh and had no issues, also with no curlrc

fwiw I tested on an m1 mbp and in both rosetta and with a native node, no issues anywhere for me

@ljharb
Copy link
Contributor

ljharb commented Feb 3, 2021

oooops, lol, i had a curlrc with --remote-name-all, specifically to trigger this scenario for when nvm forgets to use -q (to bypass the curlrc). Perhaps the curls inside the script could use that?

@nlf nlf pinned this issue Feb 3, 2021
@wraithgar wraithgar changed the title [BUG] npm is broken after updating to npm@7 when using node 8 [BUG] npm is broken after updating to npm@7 when using node 8 or older Feb 3, 2021
@nlf
Copy link
Contributor

nlf commented Feb 3, 2021

we can patch the script to pass a -q in the calls there and change our advised command to install to include it

@tuchidoghostmaster
Copy link

Getting same error trying to deploy to Heroku:
Screen Shot 2021-02-03 at 10 51 38 AM

Hi, I have solved it.

  • In the filepackage.json please using :
...
"engines": {
    "node": "8.11.3",
    "npm": "6.14.11"
 },
...

Then it will work for you.

@ljharb
Copy link
Contributor

ljharb commented Feb 4, 2021

@tuchidoghostmaster the npm >= 3.10 is what's broken - npm 7+ can't ever work on node 8. Try fixing the "engines" field's "npm" property in your package json to be ^3 || ^4 || ^5 || ^6, for example.

@tuchidoghostmaster
Copy link

@ljharb yes, i'm updated, using node 8 and npm 6+ working for me now. see comment #2599 (comment)

@phil-warner
Copy link

I'm getting the exact same error. I was running Node 12.18 and tried upgrading to 14.15.4, which came with npm 6.14.1, which didn't fix it. Then tried to upgrade npm, but got the error again.

GeoWill added a commit to GeoWill/UK-Polling-Stations that referenced this issue Feb 10, 2021
GeoWill added a commit to GeoWill/UK-Polling-Stations that referenced this issue Feb 10, 2021
GeoWill added a commit to DemocracyClub/polling_deploy that referenced this issue Feb 10, 2021
GeoWill added a commit to DemocracyClub/UK-Polling-Stations that referenced this issue Feb 10, 2021
@darcyclarke darcyclarke removed the Needs Triage needs review for next steps label Feb 24, 2021
@valdiss
Copy link

valdiss commented May 31, 2021

I don't know if this is allowed or not to talk about third party packages but I discovered npm-check-updates today, it solves the npm update problem for me... If that can help anyone!

@darcyclarke darcyclarke changed the title [BUG] npm is broken after updating to npm@7 when using node 8 or older 🐞 [BUG] npm is broken after updating to npm@7 when using node 8 or older Jun 2, 2021
@npm npm locked as resolved and limited conversation to collaborators Jun 2, 2021
@darcyclarke darcyclarke changed the title 🐞 [BUG] npm is broken after updating to npm@7 when using node 8 or older 🐞 [BUG] npm@7 is broken on node@8 or older Aug 17, 2021
@darcyclarke darcyclarke unpinned this issue Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests