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

node v12.18.3 doesn't work with npm v6.9.2 and below #34491

Closed
AdirAmsalem opened this issue Jul 23, 2020 · 14 comments
Closed

node v12.18.3 doesn't work with npm v6.9.2 and below #34491

AdirAmsalem opened this issue Jul 23, 2020 · 14 comments
Labels
npm Issues and PRs related to the npm client dependency or the npm registry. wrong repo Issues that should be opened in another repository.

Comments

@AdirAmsalem
Copy link

AdirAmsalem commented Jul 23, 2020

  • 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 - jprichardson/node-fs-extra#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

@hamoudchohan
Copy link

Facing the same issue on Ubuntu 20.04.

npm ERR! cb.apply is not a function

@shivarv
Copy link

shivarv commented Jul 23, 2020

same issue for me too in windows

@JohnLBergqvist
Copy link

Same issue for me on Ubuntu 18.04

@hamoudchohan
Copy link

I have solved the issue by upgrading my npm to 6.14.

@shivarv
Copy link

shivarv commented Jul 24, 2020 via email

@Rush
Copy link

Rush commented Jul 28, 2020

I use yarn which never broke during the last 3 years. Today I realized our electron build uses npm under the hood which broke with the error message npm ERR! cb.apply is not a function.

@bnoordhuis
Copy link
Member

I'm afraid this is not the right place to report issues with npm, that's https://npm.community/c/bugs. Node.js bundles npm but doesn't maintain it. I'll close this out.

@bnoordhuis bnoordhuis added npm Issues and PRs related to the npm client dependency or the npm registry. wrong repo Issues that should be opened in another repository. labels Aug 1, 2020
@AdirAmsalem
Copy link
Author

AdirAmsalem commented Aug 1, 2020

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

@bnoordhuis
Copy link
Member

@AdirAmsalem The stack trace points to a polyfill in one of npm's modules, that's not something node can fix. You can see for yourself:

function statFix (orig) {
if (!orig) return orig
// Older versions of Node erroneously returned signed integers for
// uid + gid.
return function (target, options, cb) {
if (typeof options === 'function') {
cb = options
options = null
}
function callback (er, stats) {
if (stats) {
if (stats.uid < 0) stats.uid += 0x100000000
if (stats.gid < 0) stats.gid += 0x100000000
}
if (cb) cb.apply(this, arguments)
}
return options ? orig.call(fs, target, options, callback)
: orig.call(fs, target, callback)
}

I have no reason to believe changes between Node.js v12.18.2 and v12.18.3 are responsible.

@tktcorporation
Copy link

tktcorporation commented Aug 1, 2020

I had same issue on Windows 10.
and I used nodist to install node. it may be the cause I think.

I tried to install node with choco install -y nodejs.install.
then, npm i works fine.
(before that, nodist was uninstalled)

@roni-castro
Copy link

roni-castro commented Aug 5, 2020

I had to add a resolution to fix this problem, because other libs in my project uses the old version of graceful-fs, which apparently have this problem:

package.json

  "resolutions": {
    "graceful-fs": "4.2.4"
  },

@iamstarkov
Copy link

graceful-fs workaround doesnt help

@roni-castro
Copy link

roni-castro commented Aug 5, 2020

graceful-fs workaround doesnt help

Open you yarn.lock or package.lock and check which dependencies uses graceful-fs. I have a lot of dependencies that needs this lib as a subdependency, and I currently added the resolution to make all the caret version be resolved to 4.2.4. Open a new issue with the description of your problem if don't find any solution, but I think the problem was on the version < 4.1.15 of graceful-fs, not on node.

This change fixed my problem:
// package.json 
 "resolutions": {
    "graceful-fs": "4.2.4"
  },


// yarn.lock
graceful-fs@4.2.4, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
  version "4.2.4"
  resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
  integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==

@iamstarkov
Copy link

@roni-castro I've done it and it didn't help. See here more #34529 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm Issues and PRs related to the npm client dependency or the npm registry. wrong repo Issues that should be opened in another repository.
Projects
None yet
Development

No branches or pull requests

9 participants