Javascript /npm安装路径错误
javascript/npm install path resolved incorrectly
我在一个JS项目上开始我的工作,在那里我想使用bower, grunt等。qunit-sinon
是我项目的主目录:
tducin@home:~/Development/qunit-sinon (grunt)$ ll
razem 192
drwxrwxr-x 5 tducin tducin 4096 sie 24 11:45 ./
drwxrwxr-x 3 tducin tducin 4096 sie 23 18:00 ../
drwxrwxr-x 5 tducin tducin 4096 sie 23 18:18 bower_components/
-rw-rw-r-- 1 tducin tducin 458 sie 23 18:15 bower.json
drwxrwxr-x 8 tducin tducin 4096 sie 24 11:42 .git/
-rw-rw-r-- 1 tducin tducin 552 sie 23 20:46 .gitignore
-rw-rw-r-- 1 tducin tducin 1148 sie 24 11:41 Gruntfile.js
-rw-rw-r-- 1 tducin tducin 485 sie 23 18:26 index.html
-rw-rw-r-- 1 tducin tducin 1079 sie 23 20:45 LICENSE
drwxrwxr-x 4 tducin tducin 4096 sie 24 11:46 node_modules/
-rw-rw-r-- 1 tducin tducin 140356 sie 24 11:45 npm-debug.log
-rw-rw-r-- 1 tducin tducin 346 sie 24 11:44 package.json
-rw-rw-r-- 1 tducin tducin 324 sie 23 18:30 README.md
-rw-rw-r-- 1 tducin tducin 1402 sie 24 11:00 tests.js
我已经安装了以下全局:node/npm, bower, grunt-cli。我用grunt-init gruntfile
来初始化Gruntfile.js
。我的package.json
内容为:
tducin@home:~/Development/qunit-sinon (grunt)$ cat package.json
{
"engines": {
"node": ">= 0.10.0"
},
"repository": {
"type": "git",
"url": "git://github.com/tkoomzaaskz/qunit-sinon"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-qunit": "~0.5.2",
"grunt-contrib-watch": "~0.6.1"
}
}
现在我想运行npm install
安装所有缺失的模块(少数grunt插件有自动添加到Gruntfile.js),然后我得到以下错误:
tducin@home:~/Development/qunit-sinon (grunt)$ npm install
npm ERR! Error: EACCES, mkdir '/home/tducin/.npm/underscore/1.6.0'
npm ERR! { [Error: EACCES, mkdir '/home/tducin/.npm/underscore/1.6.0']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/tducin/.npm/underscore/1.6.0',
npm ERR! parent: 'jshint' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.13.0-34-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/tducin/Development/qunit-sinon
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! path /home/tducin/.npm/underscore/1.6.0
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/tducin/.npm/underscore/1.6.0'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/tducin/Development/qunit-sinon/npm-debug.log
npm ERR! not ok code 0
npm想要全局安装——这就是为什么他想要管理员权限。但这不是我想做的。
我很肯定这个错误的原因是很明显的,然而,我不知道。请解释为什么npm试图安装在/home/tducin/.npm
(全局)而不是我的本地项目node_modules
目录。
我不能评论,因为rep…
调试日志中有什么吗?/home/tducin/Development/qunit-sinon/npm-debug.log
它看起来不像是试图全局安装,因为全局模块通常在/usr/local/lib/node_modules
或/usr/lib/node_modules
请张贴结果:
ls -l -a /home/tducin/ | grep npm
由于.npm文件夹可能已经被创建为根目录
好吧,过了一段时间,我遇到了类似的问题。事实上,我是~/.npm
目录本身的所有者,而不是根目录的所有者。但我的问题是,~/.npm
的一些内容是我的,有些是根的。这就是为什么一些模块安装成功而另一些模块安装失败的原因。这可能是因为我使用npm install的方式不对。
下面的命令修复了这个问题:
sudo chown -R tducin:tducin ~/.npm
相关文章:
- javascript window.location在检查firebug时给了我一个错误的url路径
- 最短路径算法js错误
- AngularFire 0.5美元移除.错误:Firebase.child失败:第一个参数是无效路径
- windows文件系统中的nodejs路径错误4058 ENOENT
- 路径错误中的非法字符
- 使用Raphael.js绘制双动画路径错误
- Javascript /npm安装路径错误
- 流星,NGINX子路径错误
- Grunt Dist文件夹相对路径错误
- 为什么在Durandal Get started教程中,text.js的请求路径错误?
- SVG路径错误"d"属性
- 弹出asp.net页面,javascript和路径错误404
- 在Ember项目中包含外部JS文件的路径错误(不确定)
- Extract-text-webpack-plugin输出CSS文件,图像路径错误
- Nodejs中的相对路径错误
- Webpack,新块加载路径错误
- 使用Ajax访问其他目录中的文件时出现问题,是我指定的路径错误吗
- IE8上的jQuery选择器路径错误
- 木偶.js需要.js模板路径错误
- Firebase child_added事件返回无效路径错误