首页 > 解决方案 > 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 ]

标签: node.jsangularnpm

解决方案


您可以看到,问题源于您当前的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。这肯定会成功。


推荐阅读