天翻地覆与NPM更新-g(SNAFU with npm update -g)

2019-10-21 10:32发布

我试图更新npm和全乱套了:

Environment check
✔ $HOME
✔ Yo
✔ Compass
✔ Ruby
✔ Git
✔ Node.js
✔ npm
dist: $ npm update -g
npm http GET https://registry.npmjs.org/envcheck
npm http GET https://registry.npmjs.org/bower
npm http GET https://registry.npmjs.org/generator-h5bp
npm http GET https://registry.npmjs.org/generator-mocha
npm http GET https://registry.npmjs.org/generator-zf5
npm http GET https://registry.npmjs.org/headstart
npm http GET https://registry.npmjs.org/cordova
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/generator-webapp
npm http GET https://registry.npmjs.org/yeoman-foundation
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/phonegap
npm http GET https://registry.npmjs.org/npm
npm http 200 https://registry.npmjs.org/generator-h5bp
npm http GET https://registry.npmjs.org/yeoman-generator
npm http 200 https://registry.npmjs.org/envcheck
npm http 200 https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/generator-zf5
npm http 200 https://registry.npmjs.org/headstart
npm http 200 https://registry.npmjs.org/generator-mocha
npm http 200 https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/resolve
npm http 200 https://registry.npmjs.org/cordova
npm http 200 https://registry.npmjs.org/generator-webapp
npm http 200 https://registry.npmjs.org/yeoman-foundation
npm http 200 https://registry.npmjs.org/nopt
npm http 200 https://registry.npmjs.org/yeoman-generator
npm http 200 https://registry.npmjs.org/resolve
npm http 304 https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http 200 https://registry.npmjs.org/yo
npm http 200 https://registry.npmjs.org/phonegap
npm http 200 https://registry.npmjs.org/glob
npm http 200 https://registry.npmjs.org/lodash
npm http 200 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/-/npm-2.1.14.tgz
npm http GET https://registry.npmjs.org/bower/-/bower-1.3.12.tgz
npm http GET https://registry.npmjs.org/envcheck/-/envcheck-1.1.0.tgz
npm http GET https://registry.npmjs.org/generator-zf5/-/generator-zf5-0.9.5.tgz
npm http GET https://registry.npmjs.org/generator-mocha/-/generator-mocha-0.1.6.tgz
npm http GET https://registry.npmjs.org/headstart/-/headstart-1.3.1.tgz
npm http GET https://registry.npmjs.org/generator-webapp/-/generator-webapp-0.5.1.tgz
npm http GET https://registry.npmjs.org/yo/-/yo-1.3.3.tgz
npm http GET https://registry.npmjs.org/cordova/-/cordova-4.1.3-nightly.2014.10.21.tgz
npm http GET https://registry.npmjs.org/phonegap/-/phonegap-4.1.2-0.22.10.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt'
npm ERR! error rolling back  nopt@1.0.10 { [Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt' }
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt'
npm ERR!  { [Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "update" "-g"
npm ERR! cwd /Volumes/3 TB LaCie/* Projects/14-03157 Frontgate Windows App/Working/app/bower_components/bootstrap/dist
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path /usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/.bin/nopt'
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/generator-h5bp/node_modules/yeoman-generator'
npm ERR! error rolling back  yeoman-generator@0.14.2 { [Error: EACCES, unlink '/usr/local/lib/node_modules/generator-h5bp/node_modules/yeoman-generator']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/generator-h5bp/node_modules/yeoman-generator' }
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/findup-sync/node_modules/glob'
npm ERR! error rolling back  glob@3.2.11 { [Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/findup-sync/node_modules/glob']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/grunt-cli/node_modules/findup-sync/node_modules/glob' }
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/resolve'
npm ERR! error rolling back  resolve@0.3.1 { [Error: EACCES, unlink '/usr/local/lib/node_modules/grunt-cli/node_modules/resolve']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/grunt-cli/node_modules/resolve' }
npm http 200 https://registry.npmjs.org/bower/-/bower-1.3.12.tgz
npm http 200 https://registry.npmjs.org/generator-mocha/-/generator-mocha-0.1.6.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/generator-mocha'
npm ERR! error rolling back  generator-mocha@0.1.6 { [Error: EACCES, unlink '/usr/local/lib/node_modules/generator-mocha']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/generator-mocha' }
npm http 200 https://registry.npmjs.org/headstart/-/headstart-1.3.1.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/headstart'
npm ERR! error rolling back  headstart@1.3.1 { [Error: EACCES, unlink '/usr/local/lib/node_modules/headstart']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/headstart' }
npm http 200 https://registry.npmjs.org/generator-webapp/-/generator-webapp-0.5.1.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/generator-webapp'
npm ERR! error rolling back  generator-webapp@0.5.1 { [Error: EACCES, unlink '/usr/local/lib/node_modules/generator-webapp']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/generator-webapp' }
npm http 200 https://registry.npmjs.org/cordova/-/cordova-4.1.3-nightly.2014.10.21.tgz
npm http 200 https://registry.npmjs.org/generator-zf5/-/generator-zf5-0.9.5.tgz
npm http 200 https://registry.npmjs.org/envcheck/-/envcheck-1.1.0.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/envcheck'
npm ERR! error rolling back  envcheck@1.1.0 { [Error: EACCES, unlink '/usr/local/lib/node_modules/envcheck']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/envcheck' }
npm http 200 https://registry.npmjs.org/phonegap/-/phonegap-4.1.2-0.22.10.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/bower'
npm ERR! error rolling back  bower@1.3.12 { [Error: EACCES, unlink '/usr/local/lib/node_modules/bower']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/bower' }
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/cordova'
npm ERR! error rolling back  cordova@4.1.3-nightly.2014.10.21 { [Error: EACCES, unlink '/usr/local/lib/node_modules/cordova']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/cordova' }
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/generator-zf5'
npm ERR! error rolling back  generator-zf5@0.9.5 { [Error: EACCES, unlink '/usr/local/lib/node_modules/generator-zf5']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/generator-zf5' }
npm http 200 https://registry.npmjs.org/yo/-/yo-1.3.3.tgz
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/yo'
npm ERR! error rolling back  yo@1.3.3 { [Error: EACCES, unlink '/usr/local/lib/node_modules/yo']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/yo' }
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/phonegap'
npm ERR! error rolling back  phonegap@4.1.2-0.22.10 { [Error: EACCES, unlink '/usr/local/lib/node_modules/phonegap']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/phonegap' }
npm http 200 https://registry.npmjs.org/npm/-/npm-2.1.14.tgz
sudonpm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! error rolling back  npm@2.1.14 { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/npm' }
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Volumes/3 TB LaCie/* Projects/14-03157 Frontgate Windows App/Working/app/bower_components/bootstrap/dist/npm-debug.log
npm ERR! not ok code 0
dist: $ sudo npm update -g

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
sudo: npm: command not found
dist: $ npm update
-bash: /usr/local/bin/npm: No such file or directory
dist: $ cd /
/: $ npm update -g
-bash: /usr/local/bin/npm: No such file or directory
/: $ npm --version
-bash: /usr/local/bin/npm: No such file or directory
/: $ where npm
-bash: where: command not found
/: $ which npm
/: $ envcheck
-bash: /usr/local/bin/envcheck: No such file or directory
/: $ curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    797      0 --:--:-- --:--:-- --:--:--   800
sh: line 1: html: No such file or directory
sh: line 2: syntax error near unexpected token `<'
'h: line 2: `<head><title>301 Moved Permanently</title></head>
/: $ npm update -g
-bash: /usr/local/bin/npm: No such file or directory
/: $ envcheck
-bash: /usr/local/bin/envcheck: No such file or directory
/: $ curl https://npmjs.org/install.sh | sudo sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    163      0  0:00:01  0:00:01 --:--:--   164
sh: line 1: html: No such file or directory
sh: line 2: syntax error near unexpected token `<'
'h: line 2: `<head><title>301 Moved Permanently</title></head>
/: $ npm update
-bash: /usr/local/bin/npm: No such file or directory

没有什么工作。 不约曼,鲍尔,咕噜,等所有的和更新。

我做错什么了吗?

我应该怎么做不同?

到底什么做我现在做什么?

仅供参考,我还在学习Unix的CLI这么说,慢慢地,请:-)

先感谢您。

Answer 1:

当升级由于权限问题失败(这是这里发生了什么事......“EACCES”基本上意味着拒绝访问),这通常意味着节点/ NPM最初安装在您需要的位置sudo访问。 这被认为是不好的做法,但它很容易为初学者,因为sudo让一切“只是工作”自动的,无论你在哪里安装。 而现在的升级过程中,您没有使用sudo ,这可能会改变有访问文件,而其他人抛出错误和保持不变。

所以:

我做错什么了吗? 是。 最有可能的,安装节点的过程中,你使用sudo 。 通过这样做,你最引起未来命令需要sudo为好。 但你并没有第一次升级尝试过程中使用它。

我应该怎么做不同? 它是可能的,如果你曾经使用sudo为第一初始升级尝试,它会工作。 第二次,当你做了包括sudo ,失败的原因是第一次尝试(不sudo )摧毁了你的使用能力npm在所有命令。 因此,它失败出于不同的原因。

到底什么做我现在做什么? 重新安装从无到有是唯一可靠的方法。 如果你是为它,尽量做到不使用工作sudo的。 这样,就保证了未来的命令,有或没有sudo ,将有足够的访问权限,有自己的预期效果。

要完全重新安装,使您的机器清洁和光亮再次,在这里看到: 如何完全卸载的Node.js,并从开始重新安装(Mac OS X中)

我强烈建议使用自制的做法。 如果你试图使用sudo是出于习惯,它会骂你。



文章来源: SNAFU with npm update -g