Install and configure nodejs tools on linux, set environment variables, set npm domestic mirror source, and improve download speed.

foreword


The original link of this article is:
https://blog.csdn.net/freewebsys/article/details/108971807

Not to be reproduced without permission of the blogger.
The blogger’s CSDN address is: https://blog.csdn.net/freewebsys
The blogger’s nugget address is: https://juejin.cn/user/585379920479288
The blogger’s Zhihu address is: https://www.zhihu. com/people/freewebsystem

1. About nodejs


The basic toolkit for front-end projects, just like java's JDK.
Project address: https://nodejs.org/en/download

2. Configure environment variables


Because the system disk of the computer is relatively small, it is placed in the data disk. Download the linux package and unzip it.

export NODE_HOME=/data/opt/node
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules

Check the version:
node -v
v18.15.0

npm -v
9.5.0

Set the domestic npm mirror address, so that the download speed is fast:
https://npmmirror.com/

npm config set registry https://registry.npmmirror.com

或者执行的时候设置:
npm install xxx  --registry=https://registry.npmmirror.com

3. Summary


When using nodejs, you need to put the configuration on another disk, otherwise the system disk will be full soon.
The related libraries used will also increase the number of disk files.
After configuring the source, it is much faster to use npm to install.

The original link of this article is:
https://blog.csdn.net/freewebsys/article/details/108971807

insert image description here

Guess you like

Origin blog.csdn.net/freewebsys/article/details/129701584