help icon indicating copy to clipboard operation
help copied to clipboard

error cb.apply is not a function

Open allaura-dev opened this issue 6 years ago • 112 comments

  • Node.js Version: { npm: '4.6.1', ares: '1.16.0', brotli: '1.0.7', cldr: '37.0', icu: '67.1', llhttp: '2.0.4', modules: '83', napi: '6', nghttp2: '1.41.0', node: '14.6.0', openssl: '1.1.1g', tz: '2020a', unicode: '13.0', uv: '1.38.1', v8: '8.4.371.19-node.12', zlib: '1.2.11' }
  • OS: Windows 10
  • Scope (install, code, runtime, meta, other?): runtime

I can not do anything with my npm as I keep receiving "error cb.apply is not a function"

  • I have tried to clear the cache but it can not due to this error
  • I removed everything to do with does and the tools it downloads with it and reinstalled with windows up to date then rebooted but still receive the same error -i have tried npm doctor but failed due to this error
  • I have checked the path is correct for nodejs and node_modules How can i fix this issue?

Error chache information

0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\allie\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'install' 1 verbose cli ] 2 info using [email protected] 3 info using [email protected] 4 verbose config Skipping project config: C:\Users\allie/.npmrc. (matches userconfig) 5 silly install loadCurrentTree 6 silly install readLocalPackageData 7 verbose stack TypeError: cb.apply is not a function 7 verbose stack at C:\Users\allie\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18 7 verbose stack at FSReqCallback.oncomplete (fs.js:169:5) 8 verbose cwd C:\Users\allie 9 verbose Windows_NT 10.0.19041 10 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\allie\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" 11 verbose node v12.18.3 12 verbose npm v4.6.1 13 error cb.apply is not a function 14 verbose exit [ 1, true ]

allaura-dev avatar Jul 23 '20 15:07 allaura-dev

I solved it on both my computers. One needed more work on it. Option 1: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one npm cache folder. Run npm clean cache —force ( — force is now required to clean cache) You should be good now if not do option 2.

Option 2: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one mom cache folder. Run npm clean cache —force ( — force is now required to clean cache) Make sure everything to do with Nodejs is deleted and uninstalled. Reinstall Nodejs. You should be good now.

Thank you very much option 1 helped a 2 hour problem

SrikanthCM avatar Aug 16 '20 10:08 SrikanthCM

I found resolve in downgrading to Node 12.18.2 as the graceful-fs that was being used was hard linked by an older dependency of mine. For the lazy (Linux):

NODE_VERSION=12.18.2
curl -sSL "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" | sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v$NODE_VERSION-linux-x64/bin/node

For me, this seemed to be the only solution on WSL. WSL2 / debian sid

xaviergmail avatar Aug 16 '20 17:08 xaviergmail

Getting this exact error on macOS 10.15.6

It seems that you can use npm root -g to find the directory which is not AppData\Roaming on a mac. Though in my case it turned out I had an old ~/node_modules/ lying around causing problems. When I deleted it this problem went away.

I didn't have any duplicate node_modules at npm -g root. I deleted all global packages except npm. But this problem still exists.

I faced this while trying to serve a static website

$ ls
public
$ npx serve public/
npm ERR! cb.apply is not a function

detj avatar Aug 19 '20 13:08 detj

First option worked for me, though for some reason I had to do

npm cache clean --force

(cache and clean reversed from the original instructions)

bricechilders avatar Aug 20 '20 14:08 bricechilders

I solved it on both my computers. One needed more work on it. Option 1: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one npm cache folder. Run npm clean cache —force ( — force is now required to clean cache) You should be good now if not do option 2.

Option 2: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one mom cache folder. Run npm clean cache —force ( — force is now required to clean cache) Make sure everything to do with Nodejs is deleted and uninstalled. Reinstall Nodejs. You should be good now.

great. This worked for me. Thanks.

seyedk1 avatar Aug 24 '20 07:08 seyedk1

I only had to delete the npm Folder => C:\Users\(your username)\AppData\Roaming\npm\node_modules\npm

Then it worked again.

Deleting all files ... just took way to long 😁

negue avatar Aug 24 '20 13:08 negue

option 2 worked absolutly fine for me ! great

ajaysingh0419 avatar Aug 27 '20 04:08 ajaysingh0419

Neither of them have worked for me. Still getting this error

"Vue CLI v4.5.4 ✨ Creating project in C:\Users\TAustin\maevnsite. � Initializing git repository... ⚙️ Installing CLI plugins. This might take a while...

npm ERR! Windows_NT 10.0.18363 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\TAustin\node_modules\npm\bin\npm-cli.js" "install" "--loglevel" "error" npm ERR! node v14.8.0 npm ERR! npm v3.10.10

npm ERR! cb.apply is not a function npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request: npm ERR! C:\Users\TAustin\maevnsite\npm-debug.log ERROR command failed: npm install --loglevel error".

Not sure what else I should do

EDIT: My npm says its v3.10.10 in the error but it is 6.14 when I run npm -v.....

Tuckett45 avatar Aug 27 '20 14:08 Tuckett45

Have the same issume under https://github.com/aleen42/PersonalWiki/runs/1039544585?check_suite_focus=true, it seems that [email protected] has broken under [email protected] or [email protected]. To work around this, I have used https://github.com/actions/setup-node to setup [email protected] and [email protected], both of them worked.

aleen42 avatar Aug 28 '20 02:08 aleen42

I was able to just switch node version with nvm, nvm use 10

Sford4 avatar Sep 04 '20 22:09 Sford4

Thanks it is worked for me

madhu-ounce avatar Sep 09 '20 10:09 madhu-ounce

How do I unsubscribe from this thread, anyone?

On Wed, 9 Sep 2020 at 11:58, Madhukar reddy [email protected] wrote:

Thanks it is worked for me

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/2874#issuecomment-689487044, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACICTQGWMITDH6T3JHFAA33SE5NWZANCNFSM4PF3RVEA .

Naz786 avatar Sep 09 '20 11:09 Naz786

@Naz786 There’s a link on the right-hand side in the github interface:

Screenshot from 2020-09-09 13-09-20

If you’re using email notifications, which it looks like you might be doing, there’s also an “unsubscribe” link at the bottom of the email (in the footer).

addaleax avatar Sep 09 '20 11:09 addaleax

Thank you. 😊

On Wed, 9 Sep 2020 at 12:11, Anna Henningsen [email protected] wrote:

@Naz786 https://github.com/Naz786 There’s a link on the right-hand side in the github interface:

[image: Screenshot from 2020-09-09 13-09-20] https://user-images.githubusercontent.com/899444/92591235-cceb9580-f29d-11ea-8b3d-92d6fab85af4.png

If you’re using email notifications, which it looks like you might be doing, there’s also an “unsubscribe” link at the bottom of the email (in the footer).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/2874#issuecomment-689492638, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACICTQE3AM7HDUMINYZYDV3SE5PE5ANCNFSM4PF3RVEA .

Naz786 avatar Sep 09 '20 11:09 Naz786

I solved it on both my computers. One needed more work on it. Option 1: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one npm cache folder. Run npm clean cache —force ( — force is now required to clean cache) You should be good now if not do option 2.

Option 2: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one mom cache folder. Run npm clean cache —force ( — force is now required to clean cache) Make sure everything to do with Nodejs is deleted and uninstalled. Reinstall Nodejs. You should be good now.

this saved my day was stuck for about 2-3 days now thanks @allaura-dev

HumayounBaig avatar Sep 09 '20 18:09 HumayounBaig

I have this problem when installing gitbook, and I install a lower version(version 10, the latest is version 14), the problem just goes away.

andy380743909 avatar Sep 10 '20 10:09 andy380743909

I didn't have the problem with gitbook but this guide by flavioscopes helped me by commenting out the lines 59-62 in the affected polyfill.js file:

/*   fs.stat = statFix(fs.stat)
  fs.fstat = statFix(fs.fstat)
  fs.lstat = statFix(fs.lstat)
 */

keeev avatar Sep 10 '20 11:09 keeev

I solved it on both my computers. One needed more work on it. Option 1: Follow this directory C:\Users(your username)\AppData\Roaming Delete the npm folder and if there is one npm cache folder. Run npm clean cache —force ( — force is now required to clean cache) You should be good now if not do option 2.

First Option Worked for me. Thanks

rishabhshairy avatar Sep 13 '20 08:09 rishabhshairy

Thanks for the fixes above, I got it working. - but will this whole issue be fixed by the next Node version? Before I found this page, I killed 2 hours wondering why nothing was working. :(

erichlof avatar Sep 14 '20 17:09 erichlof

Can confirm that this issue still persists in 12.18.4 on macOS 10.15.6

$ node --version
v12.18.4
$ npx gatsby-cli new .
npm ERR! cb.apply is not a function

detj avatar Sep 16 '20 09:09 detj