无法更新npm?

时间:2018-06-21 13:30:50

标签: node.js npm windows-subsystem-for-linux

当我尝试为某些工作更新 NPM 时,此错误一直在发生。我以前在 Windows命令提示符中一直使用它,但在 Linux Bash

中没有使用过

npm i -g npm

Specify configs in the ini-formatted file:
/root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@5.6.0 /usr/lib/node_modules/npm
root@DESKTOP-SJPLLRG:~# npm -v
5.6.0
root@DESKTOP-SJPLLRG:~# npm i -g npm
npm ERR! path /usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each' -> '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/.stream-each.DELETE'
npm ERR!  { Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each' -> '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/.stream-each.DELETE'
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each' -> '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/.stream-each.DELETE'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'rename',
npm ERR!      path: '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each',
npm ERR!      dest: '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/.stream-each.DELETE' },
npm ERR!   stack: 'Error: EACCES: permission denied, rename \'/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each\' -> \'/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/.stream-each.DELETE\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/stream-each',
npm ERR!   dest: '/usr/lib/node_modules/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/.stream-each.DELETE',
npm ERR!   parent: 'mississippi' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-06-21T13_00_43_617Z-debug.log

有关我的环境的一些详细信息:

1)我使用Linux平台的Windows子系统来安装Node.js

2)我仅在root用户时尝试过。

3)我尝试使用此NPM update Link

中显示的某些命令更新NPM软件包

但是仍然无法执行更新。它显示以下错误

root@DESKTOP-SJPLLRG:~# npm install npm -g
-bash: /usr/bin/npm: No such file or directory
root@DESKTOP-SJPLLRG:~#

我被迫继续前进。有什么办法可以解决此错误并更新NPM吗?

编辑2:

我尝试重新安装Node.js和NpM,但弹出以下错误消息

ash@DESKTOP-SJPLLRG:~$ sudo apt-get install npm
[sudo] password for ash:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 npm : Depends: nodejs but it is not going to be installed
       Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
       Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed
       Depends: node-ansi-color-table but it is not going to be installed
       Depends: node-archy but it is not going to be installed
       Depends: node-block-stream but it is not going to be installed
       Depends: node-fstream (>= 0.1.22) but it is not going to be installed
       Depends: node-fstream-ignore but it is not going to be installed
       Depends: node-github-url-from-git but it is not going to be installed
       Depends: node-glob (>= 3.1.21) but it is not going to be installed
       Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
       Depends: node-inherits but it is not going to be installed
       Depends: node-ini (>= 1.1.0) but it is not going to be installed
       Depends: node-lockfile but it is not going to be installed
       Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
       Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
       Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
       Depends: node-gyp (>= 0.10.9) but it is not going to be installed
       Depends: node-nopt (>= 3.0.1) but it is not going to be installed
       Depends: node-npmlog but it is not going to be installed
       Depends: node-once but it is not going to be installed
       Depends: node-osenv but it is not going to be installed
       Depends: node-read but it is not going to be installed
       Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
       Depends: node-request (>= 2.25.0) but it is not going to be installed
       Depends: node-retry but it is not going to be installed
       Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
       Depends: node-semver (>= 2.1.0) but it is not going to be installed
       Depends: node-sha but it is not going to be installed
       Depends: node-slide but it is not going to be installed
       Depends: node-tar (>= 0.1.18) but it is not going to be installed
       Depends: node-underscore but it is not going to be installed
       Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

你们能为我提供重新安装Node.js和NPM的任何技术吗?

2 个答案:

答案 0 :(得分:1)

您需要清除npm的缓存
sudo npm cache clean -f

然后,更新命令
npm install -g npm

然后,删除易受攻击的人

npm审核修复程序--force

答案 1 :(得分:0)

命令输出为:

-bash: /usr/bin/npm: No such file or directory

由于某种原因,您的系统似乎不存在npm。 尝试重新安装NodeJS。