前端npm install
安装node
bash
配置环境变量
wget https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.xz
tar xf node-v14.21.3-linux-x64.tar.xz -C /data/
vim /etc/profile
export NODE_HOME=/data/node-v14.21.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile
#验证
node -v
npm -v
配置镜像源
bash
#配置默认阿里云镜像源
npm config set registry https://registry.npmmirror.com
#配置私服npm镜像源
npm config set registry https://npm.example.com.cn/ @***/***
#查看配置
npm config list
打包构建
bash
npm install
npm install --registry https://npm.example.com.cn/ @***/***
npm run build
报错解决
conf
Error: EACCES: permission denied, open /node_modules
shell
解决方案:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
vim ~/.profile
export PATH=~/.npm-global/bin:$PATH
source ~/.profile