npm WARN config global `--global`, `--local` are deprecated.解決過程實錄
報錯的原因是升級高版本 node 后,npm 沒有同步升級,才導致出現 WARN。
npm install -g npm-windows-upgrade
npm-windows-upgrade
錯誤提示:Scripts cannot be executed on this system. To fix, run the command below as Administrator in PowerShell and try again: Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
管理員運行PowerShell(win+x windows PowerShell(管理員))
控制臺錯誤:.\npm-windows-upgrade.ps1 : File C:\Users\admin\AppData\Roaming\npm\npm-windows-upgrade.ps1 cannot be loaded. The file C:\Users\admin\AppData\Roaming\npm\npm-windows-upgrade.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting executio
n policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\npm-windows-upgrade.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
刪除npm目錄下文件名為ps1的文件再次運行.\npm-windows-upgrade
控制臺提示:npm-windows-upgrade v6.0.1
Scripts cannot be executed on this system.
To fix, run the command below as Administrator in PowerShell and try again:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
PowerShell下執行Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force后再次運行npm-windows-upgrade
如果有多個版本可以升級,用上下箭頭選擇版本升級
posted on 2022-12-02 19:01 Benjamin 閱讀(279) 評論(0) 編輯 收藏 引用 所屬分類: 雜談