简体   繁体   English

NPM安装包不工作

[英]NPM install for packages not working

T hanks in advance for any help I can get. 我可以提前获得任何帮助。

I am trying to install packages like grunt, bower, and yeoman using nodejs and the NPM in my mac OSX 10.8's terminal. 我正在尝试使用nodejs和我的mac OSX 10.8终端中的NPM安装grunt,bower和yeoman等软件包。

I check node and NPM's versions to confirm they are installed correctly and have found that to be true. 我检查节点和NPM的版本以确认它们已正确安装并且发现它是真的。 However when I begin to run a command to install a package like bower, using the following: 但是,当我开始运行命令来安装像bower这样的包时,请使用以下命令:

npm install -g bower

I get various amounts of errors coming up. 我收到了各种各样的错误。 I am trying to avoid using the sudo command. 我试图避免使用sudo命令。 I tried using sudo, but afterwards I would get a response "command not found." 我尝试使用sudo,但之后我会得到一个响应“命令未找到”。 I have a feeling the packages may not be in the correct folders or directories but I am unclear on what to do next. 我有一种感觉,包可能不在正确的文件夹或目录中,但我不知道下一步该怎么做。

For your reference these are the errors I get: 供您参考,这些是我得到的错误:

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

For privacy, I replaced my own name with the proxy myname in the paths. 为了保护隐私,我用路径中的代理myname替换了我自己的名字。 Moreover, this problem persists when I try installing grunt, and yeoman. 此外,当我尝试安装grunt和yeoman时,这个问题仍然存在。

Upon further inspection, I noticed I have two folders. 经过进一步检查,我注意到我有两个文件夹。 One named 'users' and one name 'usr.' 一个名为“用户”,一个名称为“usr”。 Within 'users', I see a folder called node_modules. 在'users'中,我看到一个名为node_modules的文件夹。 However, within 'usr/local/lib/node_modules/npm/node_modules' I noticed there is no bower, grunt, or yeoman files. 但是,在'usr / local / lib / node_modules / npm / node_modules'中,我注意到没有bower,grunt或yeoman文件。 This is just speculation, but are the files not properly installing into the necessary folders for them to be run in npm? 这只是推测,但文件没有正确安装到必要的文件夹中,以便在npm中运行?

Any help or input would be extremely appreciated! 任何帮助或输入将非常感谢!

UPDATE 10/10/14 更新 10/10/14

For people's reference, I have tried the sudo command to see if it would work, and it displays the following: 为了人们的参考,我尝试了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)

================================ However, the above is not a proper solution. ================================但是,以上不是一个合适的解决方案。 When I try running a check to see if bower is installed like by typing bower -v or bower --version or any other bower command, I get "command not found." 当我尝试运行检查以查看是否通过键入bower -v或bower --version或任何其他bower命令来安装bower时,我得到“找不到命令”。 What is going on? 到底是怎么回事?

UPDATE 10/11/14 更新10/11/14

So nothing I have tried so far has given me the ability to run the command 'npm install -g bower.' 所以到目前为止我没有尝试过任何能让我运行'npm install -g bower'命令的能力。 Out of curiosity, as I have mentioned before, I have ran the 'sudo npm install -g bower command' which appeared to install bower. 出于好奇,正如我之前提到的,我已经运行了'sudo npm install -g bower命令',它似乎安装了凉亭。 However, typing any bower commands still yields 'command not found.' 但是,键入任何bower命令仍会产生“未找到命令”。 Upon trying sudo bower commands leads to 'command not found' as well. 在尝试sudo bower命令时,也会导致“命令未找到”。 What I do not understand though is that when I run the command 'npm ls' to look at what the NPM has installed, I interestingly have a list of the following installed packages. 我不明白的是,当我运行命令'npm ls'来查看NPM安装的内容时,我有趣地得到了以下已安装软件包的列表。 You do not need to read the list as it is long, but take note of how the first item appears to be bower. 您不需要阅读列表,因为它很长,但请注意第一项似乎是凉亭。 If this is true, and it means that bower was in fact installed by npm, why therefore, are bower commands not working? 如果这是真的,这意味着bower实际上是由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

This solved the problem for me: 这解决了我的问题:

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

You shouldn't have to run npm install as sudo. 您不必将npm install作为sudo运行。

This worked for me: 这对我有用:

I basically gave my user permissions to the directory mentioned right after this -> stack Error: EACCES, unlink... , in your case it would be something like sudo chown -R USERNAME /Users/myname/ . 我基本上已经将我的用户权限授予此后提到的目录 - > stack Error: EACCES, unlink... ,在您的情况下,它将类似于sudo chown -R USERNAME /Users/myname/

For people who are new to this, don't forget to change USERNAME in the command above with your own, if you don't know your username, simply run whoami to get it. 对于不熟悉此问题的人,请不要忘记在上面的命令中更改USERNAME,如果您不知道自己的用户名,只需运行whoami即可。

After that you can install any package without the need to use sudo, npm install -g SomePackage . 之后你可以安装任何包无需使用sudo, npm install -g SomePackage

Run the global (-g) installs as admin. 以admin身份运行全局(-g)安装。

> sudo npm install -g bower

You got this error - 你有这个错误 -

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

***** UPDATE BELOW ***** *****更新下面*****

Check if it is installed and get the version 检查它是否已安装并获取版本

> bower -v

You might not be able to see bower now because it installed as admin. 您现在可能无法看到bower因为它是以管理员身份安装的。 Try getting the version number by running 尝试通过运行获取版本号

> sudo bower -v

You should see the version number now. 您现在应该看到版本号。

Take ownership of the package with chown 用chown取得包装的所有权

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

I personally take ownership of everything in the /Users/ directory. 我个人拥有/ Users /目录中的所有内容。 It is your directory and not global. 它是您的目录,而不是全局目录。

> chown <username> *

***** UPDATE 2 BELOW ***** *****更新2以下*****

It looks like it's a PATH problem now. 看起来它现在是一个PATH问题。 Do you see the npm directory in the PATH when you type 键入时,您是否在PATH中看到了npm目录?

> echo $PATH

I use MacPorts so npm and node install in the /opt/local/bin and /opt/local/sbin directories. 我使用MacPorts所以npm和节点安装在/ opt / local / bin和/ opt / local / sbin目录中。 I did a quick check on the net and it looks like you need to have the following /usr/local/bin if you installed the package from the node site. 我在网上做了一个快速检查,如果你从节点站点安装了包,你看起来需要有以下/ usr / local / bin。

Check out this article about installing node (particularly the part about the PATH. 查看这篇关于安装节点的文章(特别是关于PATH的部分)。

That link also references this article on how to modify your PATH. 该链接还引用了有关如何修改PATH的文章。

Hope that helps. 希望有所帮助。

I was having similar issues when trying to install bower through NPM. 在尝试通过NPM安装凉亭时,我遇到了类似的问题。

I am not an expert on this but was sure it was connected to $PATH and found 2 articles which in combination fixed this for me perfectly. 我不是这方面的专家,但确定它与$ PATH有关,并找到了两篇文章,它们完美地为我解决了这个问题。

The first is this gist by Dan Haerbert: https://gist.github.com/DanHerbert/9520689 第一个是Dan Haerbert的这个要点: https ://gist.github.com/DanHerbert/9520689

Dan says 丹说

"If you're a Mac Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you will see an error like this:" “如果您是Mac Homebrew用户,并且您通过Homebrew安装了节点,那么Homebrew和NPM一起工作的方式存在一个重大的哲学问题。如果您使用Homebrew安装节点然后尝试执行npm update npm -g,您将看到这样的错误:“

The error he shows is very similar to your original error. 他显示的错误与您的原始错误非常相似。

His solution is to re-install node but to make sure that NPM is not installed via homebrew since, as he says: 他的解决方案是重新安装节点,但确保NPM没有通过自制软件安装,因为他说:

npm is its own package manager and it is therefore better to have npm manage itself and its packages instead of letting Homebrew do it. npm是它自己的包管理器,因此最好让npm管理自己和它的包而不是让Homebrew这样做。 Also, using the Homebrew version of npm requires sudo to install global packages. 此外,使用Homebrew版本的npm需要sudo来安装全局包。 That's also a very bad idea. 这也是一个非常糟糕的主意。

He says to uninstall node and then re-install it with the following commands: 他说要卸载节点,然后使用以下命令重新安装它:

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

And then to finish up with 然后完成

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

This worked for me and fixed all my issues. 这对我有用,并解决了我的所有问题。 I was able to run 'npm install -g bower' without getting the error message. 我能够运行'npm install -g bower'而不会收到错误消息。

Finally, before I did the steps above, I wanted to make sure that I had fully uninstalled node & npm. 最后,在我完成上述步骤之前,我想确保完全卸载了node&npm。 To do that, I followed the following steps from stackoverflow question 11177954 , specifically from the answer by Dominic Tancredi, who says: 为此,我从stackoverflow问题11177954开始执行以下步骤,特别是Dominic Tancredi的回答,他说:

To recap, the best way (I've found) to completely uninstall node + npm is to do the following: 回顾一下,完全卸载node + npm的最好方法(我发现)是执行以下操作:

  1. go to /usr/local/lib and delete any node and node_modules 转至/ usr / local / lib并删除任何节点和node_modules
  2. go to /usr/local/include and delete any node and node_modules directory 转至/ usr / local / include并删除任何节点和node_modules目录
  3. if you installed with brew install node, then run brew uninstall node in your terminal 如果使用brew安装节点安装,则在终端中运行brew uninstall节点
  4. check your Home directory for any local or lib or include folders, and delete any node or node_modules from there 检查您的主目录中是否有本地或lib或包含文件夹,并从那里删除任何节点或node_modules
  5. go to /usr/local/bin and delete any node executable You may need to do the additional instructions as well: 转到/ 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

I hope that is of help to someone :-) 我希望对某人有所帮助:-)

I had a similar issue with my mac. 我的mac遇到了类似的问题。 I did the followings to solve the problem. 我做了以下解决问题。

  1. open 'Disk Utility' application 打开'磁盘工具'应用程序
  2. select your hard drive. 选择你的硬盘。
  3. run verify disk permissions 运行验证磁盘权限
  4. run repair disk permissions 运行修复磁盘权限

you need to chmod and change the file permission for all the files inside /Users//.config/configstore/ 你需要chmod并更改/Users//.config/configstore/中所有文件的文件权限

should work fine after that. 之后应该工作得很好。 Mac users may have to switch to root using su which they have to enable from system preferences before running chmod command. Mac用户可能必须使用su切换到root,他们必须在运行chmod命令之前从系统首选项启用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM