npm install

centos 默认安装
[root@localhost ~]# yum -y install nodejs
[root@localhost ~]# node -v
v6.17.1
[root@localhost ~]# npm -v 
3.10.10

#查看npm仓库地址
npm get registry 
#更改npm仓库地址
npm config set registry https://registry.npmjs.org/
npm config set registry https://registry.npm.taobao.org

#安装指定版本在@后面添加版本号,并可指定仓库地址
npm install -g npm@5.6.0 --registry=https://registry.npm.taobao.org


# npm -g install npm@5.6.0 --registry=https://registry.npm.taobao.org  ###以下为错误信息
- asap@2.0.5 node_modules/npm/node_modules/asap
- fstream@1.0.10 node_modules/npm/node_modules/fstream
- fstream-npm@1.2.0 node_modules/npm/node_modules/fstream-npm
- normalize-git-url@3.0.2 node_modules/npm/node_modules/normalize-git-url
- realize-package-specifier@3.0.3 node_modules/npm/node_modules/realize-package-specifier
/usr/lib
└── (empty)

npm ERR! Linux 3.10.0-862.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "-g" "install" "npm@5.6.0" "--registry=https://registry.npm.taobao.org"
npm ERR! node v6.17.1
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules/npm/node_modules/columnify
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir

npm ERR! EEXIST: file already exists, mkdir '/usr/lib/node_modules/npm/node_modules/columnify'
npm ERR! File exists: /usr/lib/node_modules/npm/node_modules/columnify
npm ERR! Move it away, and try again.
npm ERR! Linux 3.10.0-862.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "-g" "install" "npm@5.6.0" "--registry=https://registry.npm.taobao.org"
npm ERR! node v6.17.1
npm ERR! npm  v3.10.10
npm ERR! path npm-debug.log.3436820402
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'npm-debug.log.3436820402'
npm ERR! enoent ENOENT: no such file or directory, open 'npm-debug.log.3436820402'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/lib/node_modules/npm/node_modules.bundled/columnify/npm-debug.log
npm ERR! code 1
###npm命令失效

这时需卸载rpm包后,重新安装
rpm -e npm-3.10.10-1.6.17.1.1.el7.x86_64  --nodeps
rpm -e nodejs-6.17.1-1.el7.x86_64

删除npm缓存和模块
npm cache clean --force
npm install rimraf -g
rimraf node_modules

注:本例为root安装,不存在权限问题,并多次安装均失败

下载高版本node的rpm包安装
nodejs-10.24.1-1nodesource.x86_64.rpm
下载地址:https://download.csdn.net/download/zhangxueleishamo/77848815

yum源curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum clean all 
yum makecache fast

yum -y install nodejs-10.24.1-1nodesource.x86_64.rpm
[root@spug yum.repos.d]# node -v 
v10.24.1
[root@spug yum.repos.d]# npm -v
6.14.12

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疯飙的蜗牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值