- nodejs下载网址:
nodejs(LTS版本):Download | Node.js
nodejs(当前最新版):Download | Node.js
nodejs(全版本):Index of /dist/
nodejs10(最新版):Index of /dist/latest-v10.x/
nodejs11(最新版):Index of /dist/latest-v11.x/
nodejs12(最新版):Index of /dist/latest-v12.x/
- 本次使用版本:node-v12.7.0-linux-x64.tar.gz
- 解压:
tar -zxvf node-v12.7.0-linux-x64.tar.gz
- 将解压后的文件夹移动到 /usr/local/lib64 目录中:
mv node-v12.7.0-linux-x64 /usr/local/lib64/node-v12.7.0-linux-x64
- 配置环境变量:
- 打开配置文件:
vim /etc/profile
- 添加配置:
NODE_HOME=/usr/local/lib64/node-v12.7.0-linux-x64 NODE_GLOBAL=/usr/local/lib64/node-v12.7.0-linux-x64/node_global export PATH=$NODE_HOME/bin:$NODE_GLOBAL/bin:$PATH
- 刷新配置文件:
source /etc/profile
- 打开配置文件:
- 测试是否配置成功:
[root@desktop ~]# node -v v12.7.0
[root@desktop ~]# npm version { npm: '6.10.0', ares: '1.15.0', brotli: '1.0.7', cldr: '35.1', http_parser: '2.8.0', icu: '64.2', llhttp: '1.1.4', modules: '72', napi: '4', nghttp2: '1.39.1', node: '12.7.0', openssl: '1.1.1c', tz: '2019a', unicode: '12.1', uv: '1.30.1', v8: '7.5.288.22-node.16', zlib: '1.2.11' }
[root@desktop ~]# npx -v 6.10.0
- 配置目录:
npm config set prefix /usr/local/lib64/node-v12.7.0-linux-x64/node_global npm config set cache /usr/local/lib64/node-v12.7.0-linux-x64/node_cache
- 安装 vue/cli 测试:
[root@desktop ~]# npm install -g @vue/cli /usr/local/lib64/node-v12.7.0-linux-x64/bin/vue -> /usr/local/lib64/node-v12.7.0-linux-x64/lib/node_modules/@vue/cli/bin/vue.js > core-js@3.1.4 postinstall /usr/local/lib64/node-v12.7.0-linux-x64/lib/node_modules/@vue/cli/node_modules/core-js > node scripts/postinstall || echo "ignore" Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library! The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: > https://opencollective.com/core-js > https://www.patreon.com/zloirock Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -) > core-js-pure@3.1.4 postinstall /usr/local/lib64/node-v12.7.0-linux-x64/lib/node_modules/@vue/cli/node_modules/core-js-pure > node scripts/postinstall || echo "ignore" Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library! The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: > https://opencollective.com/core-js > https://www.patreon.com/zloirock Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -) > protobufjs@6.8.8 postinstall /usr/local/lib64/node-v12.7.0-linux-x64/lib/node_modules/@vue/cli/node_modules/protobufjs > node scripts/postinstall > nodemon@1.19.1 postinstall /usr/local/lib64/node-v12.7.0-linux-x64/lib/node_modules/@vue/cli/node_modules/nodemon > node bin/postinstall || exit 0 Love nodemon? You can now support the project via the open collective: > https://opencollective.com/nodemon/donate npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/@vue/cli/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) + @vue/cli@3.9.3 added 842 packages from 545 contributors in 447.525s
- 创建 sudo 链接:
sudo ln -s /usr/local/lib64/node-v12.7.0-linux-x64/bin/node /usr/bin/node sudo ln -s /usr/local/lib64/node-v12.7.0-linux-x64/bin/npm /usr/bin/npm sudo ln -s /usr/local/lib64/node-v12.7.0-linux-x64/bin/npx /usr/bin/npx
- 查看配置:
npm config ls -l
- 查看镜像:
[root@desktop ~]# npm config get registry https://registry.npmjs.org/
- 修改为淘宝镜像:
# http://npm.taobao.org 和 http://registry.npm.taobao.org 将在 2022.06.30 号正式下线和停止 DNS 解析 # http://npm.taobao.org => http://npmmirror.com # http://registry.npm.taobao.org => http://registry.npmmirror.com npm config set registry=http://registry.npmmirror.com npm install -g cnpm --registry=http://registry.npmmirror.com
CentOS 安装 nodejs
于 2019-07-27 20:09:59 首次发布