NPM安装包不能正常工作

提前得到任何帮助,我可以得到。

我正在尝试在我的mac OSX 10.8的terminal中使用nodejs和NPM安装grunt,bower和yeoman等软件包。

我检查节点和NPM的版本,以确认他们安装正确,发现是真实的。 但是,当我开始运行命令来安装像鲍尔一样的软件包时,使用以下命令:

npm install -g bower 

我得到各种各样的错误。 我试图避免使用sudo命令。 我尝试使用sudo,但事后我会得到一个响应“找不到命令”。 我有一种感觉,包可能不在正确的文件夹或目录中,但我不清楚接下来要做什么。

为了您的参考,这些是我得到的错误:

 npm ERR! Error: EACCES, unlink '/Users/myname/.node/lib/node_modules/bower/.editorconfig' npm ERR! { [Error: EACCES, unlink '/Users/myname/.node/lib/node_modules/bower/.editorconfig'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/Users/myname/.node/lib/node_modules/bower/.editorconfig' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Darwin 12.5.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "bower" npm ERR! cwd /Users/myname npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.28 npm ERR! path /Users/myname/.node/lib/node_modules/bower/.editorconfig npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, unlink '/Users/myname/.node/lib/node_modules/bower/.editorconfig' npm ERR! error rolling back Error: EACCES, unlink '/Users/myname/.node/lib/node_modules/bower /.editorconfig' npm ERR! error rolling back { [Error: EACCES, unlink '/Users/myname/.node/lib/node_modules/bower/.editorconfig'] npm ERR! error rolling back errno: 3, npm ERR! error rolling back code: 'EACCES', npm ERR! error rolling back path: '/Users/myname/.node/lib/node_modules/bower/.editorconfig' } npm ERR! not ok code 0 

为了隐私,我用path中的代理mynamereplace了我自己的名字。 而且,当我尝试安装grunt和yeoman时,这个问题依然存在。

进一步检查后,我发现我有两个文件夹。 一个叫“用户”,一个叫“usr”。 在“用户”中,我看到一个名为node_modules的文件夹。 但是,在'usr / local / lib / node_modules / npm / node_modules'中,我注意到没有bower,grunt或yeoman文件。 这只是猜测,但文件没有正确安装到必要的文件夹,他们在npm中运行?

任何帮助或input将不胜感激!

更新 10/10/14

对于人们的参考,我已经尝试了sudo命令来查看它是否会工作,并显示以下内容:

  /Users/myname/.node/bin/bower -> /Users/myname/.node/lib/node_modules/bower/bin/bower bower@1.3.12 /Users/myname/.node/lib/node_modules/bower ├── is-root@1.0.0 ├── junk@1.0.0 ├── stringify-object@1.0.0 ├── abbrev@1.0.5 ├── chmodr@0.1.0 ├── which@1.0.5 ├── osenv@0.1.0 ├── opn@1.0.0 ├── archy@0.0.2 ├── rimraf@2.2.8 ├── graceful-fs@3.0.3 ├── bower-logger@0.2.2 ├── lru-cache@2.5.0 ├── bower-endpoint-parser@0.2.2 ├── lockfile@1.0.0 ├── nopt@3.0.1 ├── retry@0.6.0 ├── tmp@0.0.23 ├── q@1.0.1 ├── semver@2.3.2 ├── p-throttler@0.1.0 (q@0.9.7) ├── request-progress@0.3.0 (throttleit@0.0.2) ├── bower-json@0.4.0 (intersect@0.0.3, deep-extend@0.2.11, graceful-fs@2.0.3) ├── fstream@1.0.2 (inherits@2.0.1) ├── shell-quote@1.4.2 (array-filter@0.0.1, array-reduce@0.0.0, array-map@0.0.0, jsonify@0.0.0) ├── mkdirp@0.5.0 (minimist@0.0.8) ├── promptly@0.2.0 (read@1.0.5) ├── fstream-ignore@1.0.1 (inherits@2.0.1, minimatch@1.0.0) ├── chalk@0.5.0 (escape-string-regexp@1.0.2, ansi-styles@1.1.0, supports-color@0.2.0, strip- ansi@0.3.0, has-ansi@0.1.0) ├── bower-config@0.5.2 (osenv@0.0.3, graceful-fs@2.0.3, optimist@0.6.1) ├── glob@4.0.6 (inherits@2.0.1, minimatch@1.0.0, once@1.3.1) ├── tar-fs@0.5.2 (pump@0.3.5, tar-stream@0.4.7) ├── decompress-zip@0.0.8 (nopt@2.2.1, mkpath@0.1.0, touch@0.0.2, readable-stream@1.1.13, binary@0.3.0) ├── request@2.42.0 (caseless@0.6.0, json-stringify-safe@5.0.0, aws-sign2@0.5.0, forever-agent@0.5.2, stringstream@0.0.4, oauth-sign@0.4.0, tunnel-agent@0.4.0, node-uuid@1.4.1, qs@1.2.2, mime-types@1.0.2, bl@0.9.3, form-data@0.1.4, tough-cookie@0.12.1, http-signature@0.10.0, hawk@1.1.1) ├── mout@0.9.1 ├── cardinal@0.4.0 (redeyed@0.4.4) ├── bower-registry-client@0.2.1 (graceful-fs@2.0.3, request-replay@0.2.0, lru-cache@2.3.1, async@0.2.10, mkdirp@0.3.5, request@2.27.0) ├── update-notifier@0.2.0 (semver-diff@0.1.0, string-length@0.1.2, latest-version@0.2.0, configstore@0.3.1) ├── inquirer@0.7.1 (figures@1.3.3, mute-stream@0.0.4, through@2.3.6, readline2@0.1.0, lodash@2.4.1, rx@2.3.12, cli-color@0.3.2) ├── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6) └── insight@0.4.3 (object-assign@1.0.0, async@0.9.0, chalk@0.5.1, os-name@1.0.1, lodash.debounce@2.4.1, tough-cookie@0.12.1, configstore@0.3.1, inquirer@0.6.0) 

================================但是,上述不是一个合适的解决scheme。 当我尝试运行一个检查,看是否像inputbower -v或者bower –version或者任何其他的bower命令来安装bower时,我会得到“command not found”。 到底是怎么回事?

更新10/11/14

所以到目前为止我没有尝试过让我有能力运行命令“npm install -g bower”。 出于好奇,正如我之前提到的,我已经运行了似乎安装凉亭的“sudo npm install -g bower命令”。 但是,input任何bower命令仍然会产生“找不到命令”。 一旦尝试sudo bower命令导致“command not found”。 我不明白的是,当我运行命令'npm ls'来查看NPM的安装,我有趣的是有一个下列安装的软件包的列表。 你不需要阅读这个列表,因为它很长,但要注意第一个项目是如何变成凉亭的。 如果这是真的,那意味着凉亭实际上是由npm安装的,那么为什么凉亭命令不起作用呢?

  /Users/myname. ├─┬ bower@1.3.12 │ ├── abbrev@1.0.5 │ ├── archy@0.0.2 │ ├─┬ bower-config@0.5.2 │ │ ├── graceful-fs@2.0.3 │ │ ├─┬ optimist@0.6.1 │ │ │ ├── minimist@0.0.10 │ │ │ └── wordwrap@0.0.2 │ │ └── osenv@0.0.3 │ ├── bower-endpoint-parser@0.2.2 │ ├─┬ bower-json@0.4.0 │ │ ├── deep-extend@0.2.11 │ │ ├── graceful-fs@2.0.3 │ │ └── intersect@0.0.3 │ ├── bower-logger@0.2.2 │ ├─┬ bower-registry-client@0.2.1 │ │ ├── async@0.2.10 │ │ ├── graceful-fs@2.0.3 │ │ ├── lru-cache@2.3.1 │ │ ├── mkdirp@0.3.5 │ │ ├─┬ request@2.27.0 │ │ │ ├── aws-sign@0.3.0 │ │ │ ├── cookie-jar@0.3.0 │ │ │ ├── forever-agent@0.5.2 │ │ │ ├─┬ form-data@0.1.4 │ │ │ │ ├── async@0.9.0 │ │ │ │ └─┬ combined-stream@0.0.5 │ │ │ │ └── delayed-stream@0.0.5 │ │ │ ├─┬ hawk@1.0.0 │ │ │ │ ├── boom@0.4.2 │ │ │ │ ├── cryptiles@0.2.2 │ │ │ │ ├── hoek@0.9.1 │ │ │ │ └── sntp@0.2.4 │ │ │ ├─┬ http-signature@0.10.0 │ │ │ │ ├── asn1@0.1.11 │ │ │ │ ├── assert-plus@0.1.2 │ │ │ │ └── ctype@0.5.2 │ │ │ ├── json-stringify-safe@5.0.0 │ │ │ ├── mime@1.2.11 │ │ │ ├── node-uuid@1.4.1 │ │ │ ├── oauth-sign@0.3.0 │ │ │ ├── qs@0.6.6 │ │ │ └── tunnel-agent@0.3.0 │ │ └── request-replay@0.2.0 │ ├─┬ cardinal@0.4.0 │ │ └─┬ redeyed@0.4.4 │ │ └── esprima@1.0.4 │ ├─┬ chalk@0.5.0 │ │ ├── ansi-styles@1.1.0 │ │ ├── escape-string-regexp@1.0.2 │ │ ├─┬ has-ansi@0.1.0 │ │ │ └── ansi-regex@0.2.1 │ │ ├─┬ strip-ansi@0.3.0 │ │ │ └── ansi-regex@0.2.1 │ │ └── supports-color@0.2.0 │ ├── chmodr@0.1.0 │ ├─┬ decompress-zip@0.0.8 │ │ ├─┬ binary@0.3.0 │ │ │ ├── buffers@0.1.1 │ │ │ └─┬ chainsaw@0.1.0 │ │ │ └── traverse@0.3.9 │ │ ├── mkpath@0.1.0 │ │ ├── nopt@2.2.1 │ │ ├─┬ readable-stream@1.1.13 │ │ │ ├── core-util-is@1.0.1 │ │ │ ├── inherits@2.0.1 │ │ │ ├── isarray@0.0.1 │ │ │ └── string_decoder@0.10.31 │ │ └─┬ touch@0.0.2 │ │ └── nopt@1.0.10 │ ├─┬ fstream@1.0.2 │ │ └── inherits@2.0.1 │ ├─┬ fstream-ignore@1.0.1 │ │ ├── inherits@2.0.1 │ │ └─┬ minimatch@1.0.0 │ │ └── sigmund@1.0.0 │ ├─┬ glob@4.0.6 │ │ ├── inherits@2.0.1 │ │ ├─┬ minimatch@1.0.0 │ │ │ └── sigmund@1.0.0 │ │ └─┬ once@1.3.1 │ │ └── wrappy@1.0.1 │ ├── graceful-fs@3.0.3 │ ├─┬ handlebars@2.0.0 │ │ ├─┬ optimist@0.3.7 │ │ │ └── wordwrap@0.0.2 │ │ └─┬ uglify-js@2.3.6 │ │ ├── async@0.2.10 │ │ └─┬ source-map@0.1.40 │ │ └── amdefine@0.1.0 │ ├─┬ inquirer@0.7.1 │ │ ├─┬ cli-color@0.3.2 │ │ │ ├── d@0.1.1 │ │ │ ├─┬ es5-ext@0.10.4 │ │ │ │ ├── es6-iterator@0.1.1 │ │ │ │ └── es6-symbol@0.1.1 │ │ │ ├─┬ memoizee@0.3.8 │ │ │ │ ├─┬ es6-weak-map@0.1.2 │ │ │ │ │ ├── es6-iterator@0.1.1 │ │ │ │ │ └── es6-symbol@0.1.1 │ │ │ │ ├── event-emitter@0.3.1 │ │ │ │ ├── lru-queue@0.1.0 │ │ │ │ └── next-tick@0.2.2 │ │ │ └─┬ timers-ext@0.1.0 │ │ │ └── next-tick@0.2.2 │ │ ├── figures@1.3.3 │ │ ├── lodash@2.4.1 │ │ ├── mute-stream@0.0.4 │ │ ├─┬ readline2@0.1.0 │ │ │ └─┬ chalk@0.4.0 │ │ │ ├── ansi-styles@1.0.0 │ │ │ ├── has-color@0.1.7 │ │ │ └── strip-ansi@0.1.1 │ │ ├── rx@2.3.12 │ │ └── through@2.3.6 │ ├─┬ insight@0.4.3 │ │ ├── async@0.9.0 │ │ ├─┬ chalk@0.5.1 │ │ │ ├── ansi-styles@1.1.0 │ │ │ ├── escape-string-regexp@1.0.2 │ │ │ ├─┬ has-ansi@0.1.0 │ │ │ │ └── ansi-regex@0.2.1 │ │ │ ├─┬ strip-ansi@0.3.0 │ │ │ │ └── ansi-regex@0.2.1 │ │ │ └── supports-color@0.2.0 │ │ ├─┬ configstore@0.3.1 │ │ │ ├─┬ js-yaml@3.0.2 │ │ │ │ ├─┬ argparse@0.1.15 │ │ │ │ │ ├── underscore@1.4.4 │ │ │ │ │ └── underscore.string@2.3.3 │ │ │ │ └── esprima@1.0.4 │ │ │ ├── object-assign@0.3.1 │ │ │ └── uuid@1.4.2 │ │ ├─┬ inquirer@0.6.0 │ │ │ ├─┬ cli-color@0.3.2 │ │ │ │ ├── d@0.1.1 │ │ │ │ ├─┬ es5-ext@0.10.4 │ │ │ │ │ ├── es6-iterator@0.1.1 │ │ │ │ │ └── es6-symbol@0.1.1 │ │ │ │ ├─┬ memoizee@0.3.8 │ │ │ │ │ ├─┬ es6-weak-map@0.1.2 │ │ │ │ │ │ ├── es6-iterator@0.1.1 │ │ │ │ │ │ └── es6-symbol@0.1.1 │ │ │ │ │ ├── event-emitter@0.3.1 │ │ │ │ │ ├── lru-queue@0.1.0 │ │ │ │ │ └── next-tick@0.2.2 │ │ │ │ └─┬ timers-ext@0.1.0 │ │ │ │ └── next-tick@0.2.2 │ │ │ ├── lodash@2.4.1 │ │ │ ├── mute-stream@0.0.4 │ │ │ ├─┬ readline2@0.1.0 │ │ │ │ └─┬ chalk@0.4.0 │ │ │ │ ├── ansi-styles@1.0.0 │ │ │ │ ├── has-color@0.1.7 │ │ │ │ └── strip-ansi@0.1.1 │ │ │ ├── rx@2.3.12 │ │ │ └── through@2.3.6 │ │ ├─┬ lodash.debounce@2.4.1 │ │ │ ├── lodash.isfunction@2.4.1 │ │ │ ├─┬ lodash.isobject@2.4.1 │ │ │ │ └── lodash._objecttypes@2.4.1 │ │ │ └─┬ lodash.now@2.4.1 │ │ │ └── lodash._isnative@2.4.1 │ │ ├── object-assign@1.0.0 │ │ ├─┬ os-name@1.0.1 │ │ │ ├── minimist@1.1.0 │ │ │ └── osx-release@1.0.0 │ │ └─┬ tough-cookie@0.12.1 │ │ └── punycode@1.3.1 │ ├── is-root@1.0.0 │ ├── junk@1.0.0 │ ├── lockfile@1.0.0 │ ├── lru-cache@2.5.0 │ ├─┬ mkdirp@0.5.0 │ │ └── minimist@0.0.8 │ ├── mout@0.9.1 │ ├── nopt@3.0.1 │ ├── opn@1.0.0 │ ├── osenv@0.1.0 │ ├─┬ p-throttler@0.1.0 │ │ └── q@0.9.7 │ ├─┬ promptly@0.2.0 │ │ └─┬ read@1.0.5 │ │ └── mute-stream@0.0.4 │ ├── q@1.0.1 │ ├─┬ request@2.42.0 │ │ ├── aws-sign2@0.5.0 │ │ ├─┬ bl@0.9.3 │ │ │ └─┬ readable-stream@1.0.33-1 │ │ │ ├── core-util-is@1.0.1 │ │ │ ├── inherits@2.0.1 │ │ │ ├── isarray@0.0.1 │ │ │ └── string_decoder@0.10.31 │ │ ├── caseless@0.6.0 │ │ ├── forever-agent@0.5.2 │ │ ├─┬ form-data@0.1.4 │ │ │ ├── async@0.9.0 │ │ │ ├─┬ combined-stream@0.0.5 │ │ │ │ └── delayed-stream@0.0.5 │ │ │ └── mime@1.2.11 │ │ ├─┬ hawk@1.1.1 │ │ │ ├── boom@0.4.2 │ │ │ ├── cryptiles@0.2.2 │ │ │ ├── hoek@0.9.1 │ │ │ └── sntp@0.2.4 │ │ ├─┬ http-signature@0.10.0 │ │ │ ├── asn1@0.1.11 │ │ │ ├── assert-plus@0.1.2 │ │ │ └── ctype@0.5.2 │ │ ├── json-stringify-safe@5.0.0 │ │ ├── mime-types@1.0.2 │ │ ├── node-uuid@1.4.1 │ │ ├── oauth-sign@0.4.0 │ │ ├── qs@1.2.2 │ │ ├── stringstream@0.0.4 │ │ ├─┬ tough-cookie@0.12.1 │ │ │ └── punycode@1.3.1 │ │ └── tunnel-agent@0.4.0 │ ├─┬ request-progress@0.3.0 │ │ └── throttleit@0.0.2 │ ├── retry@0.6.0 │ ├── rimraf@2.2.8 │ ├── semver@2.3.2 │ ├─┬ shell-quote@1.4.2 │ │ ├── array-filter@0.0.1 │ │ ├── array-map@0.0.0 │ │ ├── array-reduce@0.0.0 │ │ └── jsonify@0.0.0 │ ├── stringify-object@1.0.0 │ ├─┬ tar-fs@0.5.2 │ │ ├─┬ pump@0.3.5 │ │ │ ├─┬ end-of-stream@1.0.0 │ │ │ │ └─┬ once@1.3.1 │ │ │ │ └── wrappy@1.0.1 │ │ │ └── once@1.2.0 │ │ └─┬ tar-stream@0.4.7 │ │ ├── bl@0.9.3 │ │ ├─┬ end-of-stream@1.1.0 │ │ │ └─┬ once@1.3.1 │ │ │ └── wrappy@1.0.1 │ │ ├─┬ readable-stream@1.0.33-1 │ │ │ ├── core-util-is@1.0.1 │ │ │ ├── inherits@2.0.1 │ │ │ ├── isarray@0.0.1 │ │ │ └── string_decoder@0.10.31 │ │ └── xtend@4.0.0 │ ├── tmp@0.0.23 │ ├─┬ update-notifier@0.2.0 │ │ ├─┬ configstore@0.3.1 │ │ │ ├─┬ js-yaml@3.0.2 │ │ │ │ ├─┬ argparse@0.1.15 │ │ │ │ │ ├── underscore@1.4.4 │ │ │ │ │ └── underscore.string@2.3.3 │ │ │ │ └── esprima@1.0.4 │ │ │ ├── object-assign@0.3.1 │ │ │ └── uuid@1.4.2 │ │ ├─┬ latest-version@0.2.0 │ │ │ └─┬ package-json@0.2.0 │ │ │ ├─┬ got@0.3.0 │ │ │ │ └── object-assign@0.3.1 │ │ │ └─┬ registry-url@0.1.1 │ │ │ └─┬ npmconf@2.1.1 │ │ │ ├─┬ config-chain@1.1.8 │ │ │ │ └── proto-list@1.2.3 │ │ │ ├── inherits@2.0.1 │ │ │ ├── ini@1.3.0 │ │ │ ├─┬ once@1.3.1 │ │ │ │ └── wrappy@1.0.1 │ │ │ └── uid-number@0.0.5 │ │ ├── semver-diff@0.1.0 │ │ └─┬ string-length@0.1.2 │ │ └─┬ strip-ansi@0.2.2 │ │ └── ansi-regex@0.1.0 │ └── which@1.0.5 ├─┬ easyimage@1.0.3 │ └── q@1.0.1 ├─┬ grunt@0.4.5 │ ├── async@0.1.22 │ ├── coffee-script@1.3.3 │ ├── colors@0.6.2 │ ├── dateformat@1.0.2-1.2.3 │ ├── eventemitter2@0.4.14 │ ├── exit@0.1.2 │ ├─┬ findup-sync@0.1.3 │ │ ├─┬ glob@3.2.11 │ │ │ ├── inherits@2.0.1 │ │ │ └─┬ minimatch@0.3.0 │ │ │ ├── lru-cache@2.5.0 │ │ │ └── sigmund@1.0.0 │ │ └── lodash@2.4.1 │ ├── getobject@0.1.0 │ ├─┬ glob@3.1.21 │ │ ├── graceful-fs@1.2.3 │ │ └── inherits@1.0.0 │ ├─┬ grunt-legacy-log@0.1.1 │ │ ├── lodash@2.4.1 │ │ └── underscore.string@2.3.3 │ ├── grunt-legacy-util@0.2.0 │ ├── hooker@0.2.3 │ ├── iconv-lite@0.2.11 │ ├─┬ js-yaml@2.0.5 │ │ ├─┬ argparse@0.1.15 │ │ │ ├── underscore@1.4.4 │ │ │ └── underscore.string@2.3.3 │ │ └── esprima@1.0.4 │ ├── lodash@0.9.2 │ ├─┬ minimatch@0.2.14 │ │ ├── lru-cache@2.5.0 │ │ └── sigmund@1.0.0 │ ├─┬ nopt@1.0.10 │ │ └── abbrev@1.0.5 │ ├── rimraf@2.2.8 │ ├── underscore.string@2.2.1 │ └── which@1.0.5 └─┬ grunt-bower-install@1.6.0 ├─┬ bower-config@0.5.2 │ ├── graceful-fs@2.0.3 │ ├── mout@0.9.1 │ ├─┬ optimist@0.6.1 │ │ ├── minimist@0.0.10 │ │ └── wordwrap@0.0.2 │ └── osenv@0.0.3 └─┬ wiredep@1.5.0 ├─┬ chalk@0.1.1 │ ├── ansi-styles@0.1.2 │ └── has-color@0.1.7 ├─┬ glob@3.2.11 │ ├── inherits@2.0.1 │ └─┬ minimatch@0.3.0 │ ├── lru-cache@2.5.0 │ └── sigmund@1.0.0 ├── lodash@1.3.1 └─┬ through2@0.4.2 ├─┬ readable-stream@1.0.33-1 │ ├── core-util-is@1.0.1 │ ├── inherits@2.0.1 │ ├── isarray@0.0.1 │ └── string_decoder@0.10.31 └─┬ xtend@2.1.2 └── object-keys@0.4.0 

这解决了我的问题:

 sudo chown -R `whoami` ~/.node/lib/node_modules/bower/ npm install -g bower bower -v 1.3.12 

你不应该运行npm install作为sudo。

这对我工作:

我基本上给了我的用户权限到这个后面提到的目录 – > stack Error: EACCES, unlink... ,在你的情况下它会像sudo chown -R USERNAME /Users/myname/

对于新手来说,不要忘了在上面的命令中用你自己的名字来更改USERNAME,如果你不知道你的用户名,只需运行whoami即可。

之后,你可以安装任何软件包, 无需使用sudo, npm install -g SomePackage

以admin身份运行全局(-g)安装。

 > sudo npm install -g bower 

你有这个错误 –

 npm ERR! Please try running this command again as root/Administrator. 

*****更新以下*****

检查它是否安装并获取版本

 > bower -v 

您现在可能无法看到凉亭,因为它安装为pipe理员。 尝试通过运行获取版本号

 > sudo bower -v 

你现在应该看到版本号。

用chown取得包的所有权

 > cd /Users/<username>/.npm > chown <username> bower* 

我个人拥有/ Users /目录中的所有权。 这是你的目录,而不是全球。

 > chown <username> * 

*****更新2下面*****

现在看起来这是一个PATH问题。 键入内容时,是否在PATH中看到npm目录?

 > echo $PATH 

我使用MacPorts,以便将npm和节点安装在/ opt / local / bin和/ opt / local / sbin目录中。 我在网上做了一个快速检查,看起来你需要有如下的/ usr / local / bin,如果你从节点站点安装软件包的话。

看看这篇关于安装节点的文章(特别是关于PATH的部分。

该链接也引用这篇文章如何修改您的path。

希望有所帮助。

在尝试通过NPM安装凉亭时,我遇到了类似的问题。

我不是这方面的专家,但确定它是连接到$ PATH,并find了两篇文章组合在一起,为我完美的解决了这个问题。

第一个是Dan Haerbert的这个要点: https ://gist.github.com/DanHerbert/9520689

丹说

“如果你是一个Mac Homebrew用户,并且你通过Homebrew安装了节点,Homebrew和NPM协同工作的一个主要的哲学问题是,如果你用Homebrew安装节点,然后尝试执行npm update npm -g,看到这样的错误:“

他显示的错误与您原来的错误非常相似。

他的解决scheme是重新安装节点,但要确保NPM不是通过自制软件安装的,因为他说:

npm是它自己的软件包pipe理器,所以最好让npm自己pipe理它的软件包,而不是让Homebrew去做。 另外,使用npm的Homebrew版本需要sudo来安装全局包。 这也是一个非常糟糕的主意。

他说要卸载节点,然后用以下命令重新安装它:

 brew install node --without-npm echo prefix=~/.node >> ~/.npmrc curl -L https://www.npmjs.org/install.sh | sh 

然后完成

 export PATH="$HOME/.node/bin:$PATH" 

这对我工作,并解决了我所有的问题。 我能够运行'npm install -g bower'而不会收到错误信息。

最后,在执行上述步骤之前,我想确保已完全卸载node&npm。 要做到这一点,我遵循从stackoverflow问题11177954 ,特别是从多米尼克·坦克雷迪的答复,谁说:

回顾一下,我发现最好的方式来完全卸载节点+ npm是做到以下几点:

  1. 去/ usr / local / lib并删除任何节点和node_modules
  2. 去/ usr / local / include并删除任何节点和node_modules目录
  3. 如果您使用brew安装节点进行安装,那么在您的terminal中运行brew卸载节点
  4. 检查您的主目录是否有本地或lib或包含文件夹,并从那里删除任何节点或node_modules
  5. 转到/ usr / local / bin并删除任何节点可执行文件您可能还需要执行其他说明:
 sudo rm /usr/local/bin/npm sudo rm /usr/local/share/man/man1/node.1 sudo rm /usr/local/lib/dtrace/node.d sudo rm -rf ~/.npm sudo rm -rf ~/.node-gyp sudo rm /opt/local/bin/node sudo rm /opt/local/include/node sudo rm -rf /opt/local/lib/node_modules 

我希望对某人有所帮助:-)

我有一个类似的问题,我的Mac。 我做了以下解决这个问题。

  1. 打开“磁盘工具”应用程序
  2. select你的硬盘。
  3. 运行validation磁盘权限
  4. 运行修复磁盘权限

您需要chmod并更改/Users//.config/configstore/中的所有文件的文件权限

应该在那之后正常工作。 在运行chmod命令之前,Mac用户可能必须使用su切换到root用户,他们必须从系统首选项启用它。