Vscode cnpm: unable to load file, but open console with CMD without error

Question:
Install CNPM on the new computer. When running CNPM-V in VSCODE terminal, the following error will be reported:

CNPM: Unable to load file
C:\Users\Administrator\AppData\ NPM \cnpm.ps1 because script is not allowed to run on this system. For more information, please refer to the
https:/go.microsoft.com/fwlink/?
about_Execution_Policies in LinkID=135170. Position line :1 character :1
cnpm -v

  + CategoryInfo          : SecurityError: (:) [],PSSecurityException
  + FullyQualifiedErrorId : UnauthorizedAccess

Solution:
(1) Run VS Code as an administrator and open a terminal in VS Code
(2) Execute Get-ExecutionPolicy at the terminal, displaying Restricted
(3) Update the PowerShell policy and execute it on the terminal: set-executionpolicy RemoteSigned
(4) Examine the status of the policy again and execute: GET-EXECUTIONPOLICY at the terminal to show the RemoteSigned igned
(5) Re-input CNPM-V problem successfully solved
Just taking notes.


Read More: