如何在特定目录中安装NPM?

时间:2015-11-01 10:15:36

标签: npm

我知道有一个duplicate here。但无论我尝试多少变化,我都会收到一条错误信息:
Error: ENOENT, stat 'd:\wamp\www\test\js\

我试过了:

npm install --prefix video.js ./wamp/www/test/js
npm install --prefix video.js ./wamp/www/test/js -g
npm install video.js ./wamp/www/test/js/video.js
npm install --localapp video.js ./wamp/www/test/js
npm install video.js D:\wamp\www\test\js -g
npm install --prefix video.js D:\wamp\www\test\js

安装video.js的正确语法是什么?

运行npm install --prefix video.js ./wamp/www/test/js会创建以下错误日志:

0 info it worked if it ends with ok
1 verbose cli [ 'E:\\Programs\\nodejs\\\\node.exe',
1 verbose cli   'E:\\Programs\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '--prefix',
1 verbose cli   'video.js',
1 verbose cli   './wamp/test/js' ]
2 info using npm@1.4.28
3 info using node@v0.10.33
4 verbose node symlink E:\Programs\nodejs\\node.exe
5 verbose cache add [ './wamp/test/js', null ]
6 verbose cache add name=undefined spec="./wamp/test/js" args=["./wamp/test/js",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url   slashes: null,
7 verbose parsed url   auth: null,
7 verbose parsed url   host: null,
7 verbose parsed url   port: null,
7 verbose parsed url   hostname: null,
7 verbose parsed url   hash: null,
7 verbose parsed url   search: null,
7 verbose parsed url   query: null,
7 verbose parsed url   pathname: './wamp/test/js',
7 verbose parsed url   path: './wamp/test/js',
7 verbose parsed url   href: './wamp/test/js' }
8 silly lockFile 16638d03-wamp-test-js ./wamp/test/js
9 verbose lock ./wamp/test/js C:\Users\steven\AppData\Roaming\npm-cache\16638d03-wamp-test-js.lock
10 silly lockFile 16638d03-wamp-test-js ./wamp/test/js
11 silly lockFile 16638d03-wamp-test-js ./wamp/test/js
12 error addLocal Could not install ./wamp/test/js
13 error Error: ENOENT, stat 'D:\wamp\www\test\js\wamp\test\js'
14 error If you need help, you may report this *entire* log,
14 error including the npm and node versions, at:
14 error     <http://github.com/npm/npm/issues>
15 error System Windows_NT 6.1.7601
16 error command "E:\\Programs\\nodejs\\\\node.exe" "E:\\Programs\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--prefix" "video.js" "./wamp/test/js"
17 error cwd D:\wamp\www\test\js
18 error node -v v0.10.33
19 error npm -v 1.4.28
20 error path D:\wamp\www\test\js\wamp\test\js
21 error code ENOENT
22 error errno 34
23 verbose exit [ 34, true ]

1 个答案:

答案 0 :(得分:0)

我认为你正在混合相对和绝对路径。您的日志文件显示了这个:

...
error Error: ENOENT, stat 'D:\wamp\www\test\js\wamp\test\js'
...

这会导致您想要使用两次的路径。

要么你需要给出绝对路径:

npm install --prefix video.js d:/wamp/www/test/js

或保持相对:

npm install --prefix video.js ./