JS
Node.js
What is Node.js?
Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser. Node.js lets developers use JavaScript to write command-line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.
NPM
Reference URL
Mirror
Option 1:
> npm config set registry https://registry.npmmirror.com
Option 2:
Alternatively, you can set the registry in the global .npmrc configuration file:
> nano ~/.npmrc
Add the following line:
registry=https://registry.npmmirror.com
Verify
To verify the change, run:
> npm config get registry
Install a Package
> npm install <package_name>
With verbose output:
> npm install <package_name> --verbose
Cache
Clear Cache
> npm cache clean --force
Troubleshooting
node : 无法将“node”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
This error occurs when the Node.js executable is not in the system PATH. To fix this issue, add the Node.js installation directory to the system PATH.
npm : 无法加载文件 npm.ps1,因为在此系统上禁止运行脚本。
This error occurs when the PowerShell execution policy is set to Restricted
. To fix this issue, run the following commands:
> get-ExecutionPolicy
> Set-ExecutionPolicy -Scope CurrentUser
Then enter RemoteSigned
when prompted.