npm升级导致npm不能使用
npm提示可以升级:
1 2 3 4 5 6 7 |
╭────────────────────────────────────────────────────────────────╮ │ │ │ New minor version of npm available! 6.13.4 → 6.14.7 │ │ Changelog: https://github.com/npm/cli/releases/tag/v6.14.7 │ │ Run npm install -g npm to update! │ │ │ ╰────────────────────────────────────────────────────────────────╯ |
按着提示执行命令 npm install -g npm,结果噩梦来了,npm 被搞崩溃了,npm命令没有了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@VM_0_16_centos ~]# npm install -g npm /usr/local/nodejs/bin/npm -> /usr/local/nodejs/lib/node_modules/npm/bin/npm-cli.js /usr/local/nodejs/bin/npx -> /usr/local/nodejs/lib/node_modules/npm/bin/npx-cli.js npm ERR! code EEXIST npm ERR! syscall symlink npm ERR! path ../../../lib/node_modules/npm/man/man1/npx.1 npm ERR! dest /usr/local/nodejs/share/man/man1/npx.1 npm ERR! errno -17 npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/npm/man/man1/npx.1' -> '/usr/local/nodejs/share/man/man1/npx.1' npm ERR! File exists: /usr/local/nodejs/share/man/man1/npx.1 npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-08-14T14_58_46_031Z-debug.log [root@VM_0_16_centos ~]# npm -v -bash: /usr/local/bin/npm: 没有那个文件或目录 |
[root@VM_0_16_centos rabbitmqdoc]# npm
-bash: /usr/local/bin/npm: 没有那个文件或目录
[root@VM_0_16_centos rabbitmqdoc]# npm
-bash: /usr/local/bin/npm: 没有那个文件或目录
重新安装 npm,如果安装过版本管理工具可以执行
n stable
或则重新拷贝npm包
cd node-v12.16.1-linux-x64/lib/
mv node_modules/ /usr/local/nodejs/lib/
使用force参数
npm install -g --force npm
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@VM_0_16_centos node-v12.16.1-linux-x64]# ls bin CHANGELOG.md include lib LICENSE README.md share [root@VM_0_16_centos node-v12.16.1-linux-x64]# cd lib/ [root@VM_0_16_centos lib]# mv node_modules/ /usr/local/nodejs/lib/ [root@VM_0_16_centos lib]# npm -v 6.13.4 [root@VM_0_16_centos lib]# npm install -g --force npm npm WARN using --force I sure hope you know what you are doing. /usr/local/nodejs/bin/npm -> /usr/local/nodejs/lib/node_modules/npm/bin/npm-cli.js /usr/local/nodejs/bin/npx -> /usr/local/nodejs/lib/node_modules/npm/bin/npx-cli.js + npm@6.14.7 added 18 packages from 4 contributors, removed 14 packages and updated 40 packages in 6.369s [root@VM_0_16_centos lib]# |
分类: linux