npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
npm config set registry https://registry.npm.taobao.org
npm config get registry
npm config set registry https://registry.npmjs.org
OS: Windows10
錯誤內容:shell
cnpm : 沒法加載文件 C:\Users\560244\AppData\Roaming\npm\cnpm.ps1,由於在此係統上禁止運行腳本。有關詳細信息,請參閱 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。 所在位置 行:1 字符: 1 + cnpm --version + ~~~~ + CategoryInfo : SecurityError: (:) [],PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
解決方法:
管理員權限運行PowerShellnpm
輸入命令: ```cmd Set-ExecutionPolicy -ExecutionPolicy RemoteSigned ``` 返回: ```cmd 執行策略更改 執行策略可幫助你防止執行不信任的腳本。更改執行策略可能會產生安全風險,如 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies 幫助主題所述。是否要更改執行策略? [Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暫停(S) [?] 幫助 (默認值爲「N」): Y ``` 選擇`Y`或者`A`
微軟的官方文檔:About Execution Policies安全