提问者:小点点

npm安装/bower安装问题和使用angular phonecat设置的不推荐使用的模块


我正在尝试运行npm install在我的终端上作为设置的一部分,为anger-phonecat按照说明https://docs.angularjs.org/tutorial

当我运行该命令时,我遇到了不推荐使用的模块的问题,并且在到达bower安装部分时出现了错误。

有人知道我如何更新已弃用的模块以避免警告,以及如何修复bower错误吗?

以下是我收到的输出:

npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
-
> fsevents@1.0.14 install /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/karma/node_modules/chokidar/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

[fsevents] Success: "/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/karma/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> angular-phonecat@0.0.0 postinstall /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat
> bower install

bower EACCES        EACCES: permission denied, unlink '/Users/Eamon/.cache/bower/registry/bower.herokuapp.com/lookup/jquery_d223e'

Stack trace:
Error: EACCES: permission denied, unlink '/Users/Eamon/.cache/bower/registry/bower.herokuapp.com/lookup/jquery_d223e'
    at Error (native)

Console trace:
Error
    at StandardRenderer.error (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/renderers/StandardRenderer.js:81:37)
    at Logger.<anonymous> (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/bin/bower.js:110:26)
    at emitOne (events.js:77:13)
    at Logger.emit (events.js:169:7)
    at Logger.emit (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/bower-logger/lib/Logger.js:29:39)
    at /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/commands/index.js:48:20
    at _rejected (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:844:24)
    at /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:870:30
    at Promise.when (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/node_modules/bower/lib/node_modules/q/q.js:788:41)
System info:
Bower version: 1.7.9
Node version: 4.4.0
OS: Darwin 15.6.0 x64

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.0
npm ERR! npm  v2.14.20
npm ERR! code ELIFECYCLE
npm ERR! angular-phonecat@0.0.0 postinstall: `bower install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the angular-phonecat@0.0.0 postinstall script 'bower install'.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bower install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-phonecat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Eamon/Documents/Scripting/Web Development/Learning/Javascript/Angularjs/angular-phonecat/npm-debug.log

我尝试搜索其他有类似问题的帖子,但这些都没有帮助我找到解决方案:

  • npm安装时出错
  • 在angular phonecat目录上运行“npm install”时出错
  • 无法npm安装angular phonecat教程:找不到模块“update notifier”

我还尝试运行sudo npm install时遇到同样的问题。我觉得鲍尔安装问题是由于设置了鲍尔缓存查看错误输出,但我不是100%确定。

有没有人在设置anger-phonecat安装时遇到类似的问题?

非常欢迎任何帮助。

非常感谢,伊蒙


共2个答案

匿名用户

问题:您(用户)没有目录的正确权限集。

立即解决的方法是使用sudo运行npm安装,但这可能会给您带来相同的错误或安装不当。

并且更改目录所有权不是一个好的选择,临时补丁。我正在回答这个问题,因为我觉得我对这个问题有一个更优雅的解决方案/建议。我多次遇到同样的问题,即“npm install -g @angular/cli”。

卸载软件包并执行以下命令(按提到的顺序)进行全新安装。

解决方案/建议:更改 npm 的默认目录(来自官方文档)

在继续前进之前备份您的计算机。

(可选)如果安装错误,请首先卸载:

npm uninstall <package-name>  # use sudo if you used it while installation
npm cache verify  # or, npm cache clean for npm version below 5.x.x 

>

  • 为全局安装创建目录:

    mkdir ~/.npm-global

    配置 npm 以使用新的目录路径:

    npm config set 前缀 '~/.npm-global'

    打开或创建~/. profile~/.bash_profile文件并添加以下行:

    < code >导出路径=~/。npm-global/bin:$PATH

    返回命令行,更新系统变量,或重新启动终端:

    源~/. profile

    (可选)测试:全局下载包,不使用 sudo。

    < code>npm install -g jshint

  • 匿名用户

    经过研究,bower似乎存在权限问题,通过使用sudo单独运行bower安装解决了问题:

    sudo bower install --allow-root
    

    然而,您不应该将sudo与bower一起使用。如果必须这样做,那么~/.cache很可能设置不正确,要么使用sudo安装,要么通过sudo安装第一个包。有关此的更多信息,请访问:http://www.competa.com/blog/2014/12/how-to-run-npm-without-sudo/

    相反,您应该通过运行以下命令来纠正所有权:

    sudo chown -R $user ~/.npm
    sudo chown -R $user ~/.config
    

    要查找用户,只需在命令行上运行以下命令:

    $ whoami
    

    如果要向更广泛的组打开,还可以将组添加到 chown 命令中。若要了解用户属于哪个组,可以键入以下命令:

    $ groups
    

    要与用户同时设置组,只需将命令更改为以下内容,并将$user和$group替换为所需的用户和组:

    sudo chown -R $user:$group ~/.npm
    sudo chown -R $user:$group ~/.config
    

    如果在npm安装过程中运行bower安装时遇到以下问题:

    EACCES: permission denied, open '/some/directory'
    EACCES: permission denied, unlink '/some/directory'
    

    您需要通过以下操作将包含文件的文件夹的权限更改为您的用户:

    sudo chown -R USER /some/directory
    

    只需更改存储文件的文件夹,而不是文件本身。当您在此之后运行 npm install 时,如果需要安装任何在使用当前用户而不使用 sudo 时安装时出现问题的 bower 组件,它将起作用。

    谢谢,伊蒙