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

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.

13.5.0 worked!!!! Thank you!!

Legion003 avatar Sep 16 '20 12:09 Legion003

I have this problem with gitbook, and solutions didn't work for me. I found this guide 👇 and solved the problem.

Change codes here C:\Users\(your username)\AppData\Roaming\npm\node_modules\gitbook-cli\node_modules\npm\node_modules\graceful-fs\polyfills.js:287 , commented out 62-64 lines.

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

jckling avatar Sep 19 '20 09:09 jckling

@blackraspberryyy solution worked for me. Thanks

popstheman avatar Sep 20 '20 11:09 popstheman

Node v12.18.4 works

jdnva avatar Sep 21 '20 21:09 jdnva

thank you very much first option works for me. I didn't try 2 option

deepak19k96 avatar Sep 25 '20 14:09 deepak19k96

Hey guys! I had this issue when I installed the second version of node/npm. Uninstalled, and now works. Maybe the issue is one cache for different versions of npm and the structure is different? c:\Users<username>\AppData\Roaming\ has 2 folders npm and npm-cache. Anyways uninstalling one of the nodes worked for me.

mapoart avatar Sep 28 '20 09:09 mapoart

Install latest version and clear the cache.

arun9989 avatar Oct 01 '20 10:10 arun9989

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.

thq very much worked first option

CartoonProgrammers avatar Oct 02 '20 08:10 CartoonProgrammers

i resolved my problem with the solution of @allaura-dev react working

gutijuarez avatar Oct 02 '20 18:10 gutijuarez

Be aware that may you have silently two installation of nmp like mine! One update installation and an old one by yarn. you can find out by reading npm error logs, in this case you will see two different npm version number in error logs and npm version command.

❯ cat /home/{user}/.npm/_logs/2020-10-03T05_34_01_238Z-debug.log
.
.
.
9 verbose stack     at /home/{user}/.config/yarn/global/node_modules/npx/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
9 verbose stack     at FSReqCallback.oncomplete (fs.js:178:5)
10 verbose cwd /.../Projects/.../new-react-prj
11 verbose Linux 5.8.12-arch1-1
12 verbose argv "/usr/bin/node" "/home/{user}/.config/yarn/global/node_modules/npx/node_modules/npm/bin/npm-cli.js" "install" "proton-native-cli@latest" "--global" "--prefix" "/home/{user}/.npm/_npx/136164" "--loglevel" "error" "--json"
13 verbose node v14.12.0
14 verbose npm  v5.1.0 #######<<<<< HERE
.
.
.

AND

❯ npm version
{
npm: '6.14.7',
ares: '1.16.1',
brotli: '1.0.9',
cldr: '37.0',
icu: '67.1',
llhttp: '2.1.2',
modules: '83',
napi: '7',
nghttp2: '1.41.0',
node: '14.12.0',
openssl: '1.1.1g',
tz: '2019c',
unicode: '13.0',
uv: '1.39.0',
v8: '8.4.371.19-node.16',
zlib: '1.2.11'
}

MaMrEzO avatar Oct 03 '20 05:10 MaMrEzO

Still facing this issue on macOS 10.15.7 & node v12.19.0

To reproduce, run this

$ node --version
$ v12.19.0

$ npm --version
$ 6.14.8

$ npx create-react-app --help
npm ERR! cb.apply is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/detj/.npm/_logs/2020-10-08T05_11_53_938Z-debug.log
Install for [ 'create-react-app@latest' ] failed with code 1

detj avatar Oct 08 '20 05:10 detj

@detj can you provide content of /Users/detj/.npm/_logs/2020-10-08T05_11_53_938Z-debug.log file too?

MaMrEzO avatar Oct 10 '20 19:10 MaMrEzO

@MaMrEzO Sorry, missed to include the logs. Here it is.

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/detj/n/bin/node',
1 verbose cli   '/usr/local/lib/node_modules/npm/bin/npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'create-react-app@latest',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   '/Users/detj/.npm/_npx/98890',
1 verbose cli   '--loglevel',
1 verbose cli   'error',
1 verbose cli   '--json'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 2f07a770c08dd5c1
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/create-react-app 583ms (from cache)
8 silly pacote tag manifest for create-react-app@latest fetched in 603ms
9 verbose stack TypeError: cb.apply is not a function
9 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:285:20
9 verbose stack     at FSReqCallback.oncomplete (fs.js:169:5)
10 verbose cwd /private/tmp
11 verbose Darwin 19.6.0
12 verbose argv "/Users/detj/n/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "install" "create-react-app@latest" "--global" "--prefix" "/Users/detj/.npm/_npx/98890" "--loglevel" "error" "--json"
13 verbose node v12.19.0
14 verbose npm  v6.9.0
15 error cb.apply is not a function
16 verbose exit [ 1, true ]

Now, I'm surprised why is npm v6.9.0 being used when I have 6.14.8 installed.

detj avatar Oct 11 '20 13:10 detj

@MaMrEzO Fixed it. npx was symlinked to a location in /usr/local/lib/node_modules/npm. Which was of version 6.9.0. this might have happened during one of my earlier node/npm installation/re-installation session.

I have cleaned everything up now and npx create-react-app --hep works. All the binaries are correctly pointing to their respective installed versions.

thanks.

detj avatar Oct 11 '20 13:10 detj

Options 1 work very fine, thank you.

DariusKopka avatar Oct 13 '20 20:10 DariusKopka

if i run the npm clean cache —force it appears that

npm WARN npm npm does not support Node.js v12.19.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10
, 11.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN npm npm does not support Node.js v12.19.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10
, 11.
npm WARN npm You can find the latest version at https://nodejs.org/

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    completion, config, create, ddp, dedupe, deprecate,
    dist-tag, docs, doctor, edit, explore, get, help,
    help-search, hook, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, profile, prune, publish, rb, rebuild, repo, restart,
    root, run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h     quick help on <command>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\Aluno\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] C:\Users\Aluno\Desktop\node js\node_modules\npm  

tskxz avatar Oct 19 '20 07:10 tskxz

@tanjilk - npm will not remove data by itself: the cache will grow as new packages are installed. hence npm clean cache —force delete all data out of the cache folder. if it doesn't work then you can manually delete the folder %appdata%\npm-cache and then install the npm install npm@latest -g hope it may help

PoojaDurgad avatar Oct 19 '20 10:10 PoojaDurgad

@allaura-dev - is this still an issue?

PoojaDurgad avatar Oct 19 '20 10:10 PoojaDurgad

I got the same issue on macOS. Here is my solution. Besides the error message above, there are other tips: npm ERR! A complete log of this run can be found in: npm ERR! /Users/xxx/.npm/_logs/2020-10-20T07_41_00_394Z-debug.log Open the file of xxx-debug.log: /// verbose cli '/usr/local/Cellar/node/14.12.0/bin/node', verbose cli '/Users/xxx/node_modules/.bin/npm', <-------!!! wrong verbose cli 'install',6 verbose cli '--loglevel', verbose cli 'error',6 verbose cli '@vue/cli-plugin-babel@~4.5.0', verbose cli '@vue/cli-plugin-eslint@~4.5.0', verbose cli '@vue/cli-service@~4.5.0', verbose cli '--save-dev'6 verbose cli ] info using [email protected] <-------!!! wrong info using [email protected] /// I found the npm version and path are wrong. I open the path of the npm of log file. cd /Users/xxx/node_modules/.bin/ then i run the command of ls -al. /// lrwxr-xr-x npm -> ../npm/bin/npm-cli.js lrwxr-xr-x npx -> ../npm/bin/npx-cli.js ///The links above point to wrong paths. The correct paths are : lrwxr-xr-x npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js lrwxr-xr-x npx -> /usr/local/lib/node_modules/npm/bin/npm-cli.js After recorrecting these links. vue works well.

Glen-Bai avatar Oct 20 '20 09:10 Glen-Bai

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.

Option 1 worked for me!! thanks a lot!!

ALVSoft avatar Oct 21 '20 18:10 ALVSoft