我已经在我的机器上安装了Node.js,但当我尝试运行npm install -g create-reactapp时,它会显示以下警告:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
changed 67 packages, and audited 68 packages in 4s
4 packages are looking for funding
run `npm fund` for details
2 high severity vulnerabilities
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
在Windows上升级npm需要手动步骤,以确保PowerShell/CMD找到新版本的npm
对于Windows用户(感谢Lars)使用这个库:
以管理员身份打开PowerShell并运行(策略信息):
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install --global --production npm-windows-upgrade
npm-windows-upgrade --npm-version latest
记得回到最初的策略:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
它很容易打开和编辑npm。如果以管理员身份登录,则使用Visual Studio Code打开cmd文件。
右键单击npm。然后选择“用代码打开”。
该文件将在Visual Studio Code中打开。
Change prefix -g
到prefix——location=global
当你完成并尝试关闭文件时,Visual Studio Code将在右下角弹出一个消息:
保存“npm”失败。cmd `:权限不足。选择“以管理员身份重试”以管理员身份重试。
单击“以管理员身份重试”。npm。CMD文件将被保存,并且在启动时不再出现警告。