如何修复cb.apply is not a function
$ node -v
v16.16.0
$ npm -v
8.11.0
$ npx -v
10.2.2
$ npx nuxi init nuxt-app
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2022-07-19T11_46_43_598Z-debug.log
L'installation de [ 'nuxi@latest' ] a échoué avec le code 1
$ cat /home/me/.npm/_logs/2022-07-19T11_46_43_598Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/bin/node',
1 verbose cli '/usr/local/lib/node_modules/npx/node_modules/npm/bin/npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'nuxi@latest',
1 verbose cli '--global',
1 verbose cli '--prefix',
1 verbose cli '/home/me/.npm/_npx/7138',
1 verbose cli '--loglevel',
1 verbose cli 'error',
1 verbose cli '--json'
1 verbose cli ]
2 info using npm@5.1.0
3 info using node@v16.16.0
4 verbose npm-session bdbc314b7bc264a3
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/nuxi 174ms
8 http fetch GET 200 https://registry.npmjs.org/nuxi/-/nuxi-3.0.0-rc.6.tgz 197ms
9 silly pacote tag manifest for nuxi@latest fetched in 395ms
10 verbose stack TypeError: cb.apply is not a function
10 verbose stack at /usr/local/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
10 verbose stack at FSReqCallback.oncomplete (node:fs:199:5)
11 verbose cwd /home/me/code
12 verbose Linux 5.15.0-41-generic
13 verbose argv "/usr/bin/node" "/usr/local/lib/node_modules/npx/node_modules/npm/bin/npm-cli.js" "install" "nuxi@latest" "--global" "--prefix" "/home/me/.npm/_npx/7138" "--loglevel" "error" "--json"
14 verbose node v16.16.0
15 verbose npm v5.1.0
16 error cb.apply is not a function
17 verbose exit [ 1, true ]
我最终通过使用nvm
修复了它。
所以,我删除nodejs:
$ sudo apt remove --purge nodejs
安装nvm
,nodejs
,npm
和我的Nuxt3项目
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
$ nvm install --lts
$ npx nuxi init nuxt-app