node.js - npm 错误!cb.apply 在执行时不是一个函数 > npm install @angular/cli@latest
问题描述
在执行以下操作时,我在 Windows 中收到此错误“npm ERR!cb.apply 不是函数”:
> npm install
我也尝试过:
> npm install @angular/cli@latest
错误是一样的,这是file.log:
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:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '@angular/cli@latest'
1 verbose cli ]
2 info using npm@5.0.3
3 info using node@v14.15.1
4 verbose npm-session f3412af9e2e7111f
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 verbose stack TypeError: cb.apply is not a function
7 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
7 verbose stack at FSReqCallback.oncomplete (fs.js:184:5)
8 verbose cwd E:\...
9 verbose Windows_NT 10.0.15063
10 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@angular/cli@latest"
11 verbose node v14.15.1
12 verbose npm v5.0.3
13 error cb.apply is not a function
14 verbose exit [ 1, true ]
解决方案
您可以看到,问题源于您当前的npm
包。
7 verbose stack TypeError: cb.apply is not a function
7 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
你的 npm 版本已经很老了。
2 info using npm@5.0.3
我们目前是 7.9.0。请跑
npm install -g npm@7.9.0
然后尝试再次安装 angular cli。这肯定会成功。
推荐阅读
- php - 找不到驱动程序(SQL:select * from ".." where ".." = user limit 1),在 vscode cli 上运行 docker-compose build 时服务“app”构建失败
- javascript - Vue - 单个文件组件未呈现
- php - 如何不仅检查保留关键字,还检查任何内置函数或“特殊变量”?
- javascript - 使用 ws 库(nodejs)的套接字 ping 错误
- c++ - vector::iterator 也可以用作向量吗
- sql - 在 oracle sql developer 中从另一个数据库的视图中更新表列
- ios - Nodejs 苹果原生认证
- asp.net-core - Ajax 调用,其中参数为 IRequest (Mediatr),所有属性都为 null
- openam - 无法创建 SMS 配置:服务器 URL 的主机名不是 openam 中的 FQD
- angular - 在 Visual Studio Code 中使用 nx 控制台给出错误无效的配置文件