我一直在关注谷歌的angular教程,但在step 7之后遇到了麻烦。
我已经像这样更新了bower.json中的依赖项(添加了"angular-route":"~1.4.0"):
{
"name": "angular-phonecat",
"description": "A starter project for AngularJS",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-phonecat",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.4.x",
"angular-mocks": "1.4.x",
"jquery": "~2.1.1",
"bootstrap": "~3.1.1",
"angular-route": "~1.4.0"
}
}下面是我输入的内容:
pavels@pavels:~/Desktop/angular-phonecat$ sudo npm install下面是我的错误:
npm WARN cannot run in wd angular-phonecat@0.0.0 bower install (wd=/home/pavels/Desktop/angular-phonecat)我对像AngularJS这样的javascript框架这样的前端工具非常陌生,我应该怎么做才能修复它呢?我哪里做错了?
嗯,我已经全局安装了bower (通过运行sudo npm install -g bower),当我试图从我正在工作的目录运行bower install时,我得到了以下结果:
/usr/local/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:46
throw err;
^
Error: EACCES, permission denied '/home/pavels/.config/configstore/insight-bower.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:500:18)
at Object.fs.readFileSync (fs.js:352:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:27:26)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/insight/node_modules/configstore/index.js:20:44)
at new Insight (/usr/local/lib/node_modules/bower/node_modules/insight/lib/index.js:37:34)
at ensureInsight (/usr/local/lib/node_modules/bower/lib/util/analytics.js:25:19)
at Object.setup (/usr/local/lib/node_modules/bower/lib/util/analytics.js:41:9)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/bin/bower:72:11)
at Module._compile (module.js:460:26)发布于 2015-09-27 01:03:32
似乎npm无法在工作目录中运行,请尝试以下命令
sudo npm install --unsafe-perm如果仍然不起作用,请尝试将以下内容添加到您的package.json中
"config": {
"unsafe-perm":true
}第三种选择是将/usr/local/lib/node_modules的所有者更改为您的user_name,然后运行npm insall而不使用sudo。
chown -R your_user_name usr/local/lib/node_modules发布于 2015-09-27 01:13:08
您有目录权限问题。我建议您更改node.js的安装方式。nvm是这个问题的一个很好的解决方案。一定要卸载所有的全局包(对于每个包,先卸载npm ls -g -depth=0,然后再卸载npm uninstall -g <package> )。然后卸载节点,然后通过nvm重新安装。这应该会解决你所有的权限问题。运行npm install时,您将不再需要使用sudo。
发布于 2015-09-27 01:37:55
您正在运行sudo npm install,因此安装脚本是以根身份执行的。安装脚本会触发bower install,但bower不允许以根用户身份执行(使用--allow-root选项除外,但事实并非如此)。
解决方案是改掉习惯,以根用户身份启动npm。您可能会遇到EACCESS错误权限,因为npm文件夹目前归根用户所有。先关注fixing npm permissions。
然后重试npm install。
https://stackoverflow.com/questions/32799289
复制相似问题