统信UOS基本开发环境搭建之node
安装 Node.js 环境并设置国内镜像,同时安装 yarn 包管理工具。通过配置环境变量和使用国内源,使得开发过程中的依赖安装更加快速高效。
# node
注意:此方法已经不推荐。建议使用系统方式安装,参考:
cp /media/psf/share/portable-linux-sync/app/node-v16.15.0-linux-x64.tar.xz ~/app
tar -xvf node-v16.15.0-linux-x64.tar.xz
rm node-v16.15.0-linux-x64.tar.xz
1
2
3
2
3
node 环境变量
vim ~/my_prifile.sh
1
加上如下配置
# node env
export NODE_HOME=/home/terwer/app/node-v16.15.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH
1
2
3
2
3
检测
➜ ~ node -v
v16.15.0
➜ ~ npm -v
8.5.5
1
2
3
4
2
3
4
安装 yarn
npm install --global yarn
1
检测
yarn -v
1
设置 node 和 yarn 为国内源
# node
npm set registry https://registry.npm.taobao.org && \npm set disturl https://npm.taobao.org/dist && \npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass && \npm set electron_mirror https://npm.taobao.org/mirrors/electron && \npm set puppeteer_download_host https://npm.taobao.org/mirrors && \npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver && \npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver && \npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs && \npm set selenium_cdnurl https://npm.taobao.org/mirrors/selenium && \npm set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector && \npm cache clean --force
# yarn
yarn config set registry https://registry.npm.taobao.org --global && \yarn config set disturl https://npm.taobao.org/dist --global && \yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass --global && \yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ --global && \yarn config set puppeteer_download_host https://npm.taobao.org/mirrors --global && \yarn config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver --global && \yarn config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver --global && \yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs --global && \yarn config set selenium_cdnurl https://npm.taobao.org/mirrors/selenium --global && \yarn config set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector --global
1
2
3
4
5
2
3
4
5
编辑 (opens new window)
上次更新: 2024/06/13, 11:48:21