profile
viewpoint

Ask questionsnode v12.18.3 doesn't work with npm v6.9.2 and below

  • Version: 12.18.3
  • Platform: (Mac) Darwin 18.7.0 Darwin Kernel Version 18.7.0; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64

What steps will reproduce the bug?

Running the following throws an error:

nvm use 12.18.3
npm i -g npm@6.9.2
npm init -y
npm i

Running the same with node 12.18.2 and npm 6.9.2 works as expected (older node versions are ok). Running the same with node 12.18.3 and npm 6.10.0 works as expected (newer npm versions are ok).

What is the expected behavior?

npm install should work.

What do you see instead?

npm ERR! cb.apply is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xxx/.npm/_logs/2020-07-23T06_52_11_776Z-debug.log

Error log content:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/xxx/.fnm/node-versions/v12.18.3/installation/bin/node',
1 verbose cli   '/var/folders/1z/j6cyfm4s2s5g4q76cb751rbm7y4sls/T/fnm-shell-478737/bin/npm',
1 verbose cli   'i'
1 verbose cli ]
2 info using npm@6.9.2
3 info using node@v12.18.3
4 verbose npm-session b6874fdb389e0e22
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall node-test@1.0.0
7 info lifecycle node-test@1.0.0~preinstall: node-test@1.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 verbose stack TypeError: cb.apply is not a function
10 verbose stack     at /Users/xxx/.fnm/node-versions/v12.18.3/installation/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:285:20
10 verbose stack     at FSReqCallback.oncomplete (fs.js:169:5)
11 verbose cwd /Users/xxx/Personal/node-test
12 verbose Darwin 18.7.0
13 verbose argv "/Users/xxx/.fnm/node-versions/v12.18.3/installation/bin/node" "/var/folders/1z/j6cyfm4s2s5g4q76cb751rbm7y4sls/T/fnm-shell-478737/bin/npm" "i"
14 verbose node v12.18.3
15 verbose npm  v6.9.2
16 error cb.apply is not a function
17 verbose exit [ 1, true ]
  • As can be seen in the logs I'm using fnm instead of nvm but that's the same.

Additional information

Might be related to the version of graceful-fs.

The following issue mentions a similar problem with regards to graceful-fs - https://github.com/jprichardson/node-fs-extra/issues/703

npm v6.10.0 and above use graceful-fs v4.2.0, while npm v6.9.2 uses graceful-fs v4.1.15. v6.10.0 Changelog - commit e36b3c320

nodejs/node

Answer questions AdirAmsalem

@bnoordhuis Thanks for the comment. I might be mistaken but, we're speaking about an old npm version which is working with Node.js up to v12.18.2 and doesn't work with Node.js v12.18.3 which was released recently. So unless I'm missing something, sounds like the issue is with Node.js and specifically the release of v12.18.3 which for some reason breaks those old npm versions. And I didn't see anything about it in the Changelog so I assume it's unintentional.

useful!
source:https://uonfu.com/
Github User Rank List