问题描述
我是这个平台的新手.
我安装了 Node.js
但是当我尝试运行命令 npm install -g @angular/cli我收到此错误:
I installed Node.js
but when I try to run command npm install -g @angular/cliI received this error:
**npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN rollback Rolling back @schematics/[email protected] failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Vivek\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@sche**
此外,当我尝试运行版本的命令时
Also when I try to run command for version
它显示了我
**C:\Users\Vivek>ng v
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'C:\Users\Vivek\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng'**
推荐答案
试试这个...
要将所有软件包更新到新的主要版本,请全局安装 npm-check-updates 软件包:
To update to a new major version all the packages, install the npm-check-updates package globally:
npm install -g npm-check-updates
然后运行 ncu:
then run ncu:
ncu -u --packageFile package.json
这会将 package.json 文件中的所有版本提示升级到依赖项和 devDependencies,因此 npm 可以安装新的主要版本.您现在已准备好运行更新:
this will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version.You are now ready to run the update:
npm update
忽略任何审核建议并再次运行安装...
ignore any audit suggestions and run install again...
npm install
这应该是弃用警告.
这篇关于安装 Angular CLI 时收到错误警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!