我之前从未使用过nodejs。我刚刚发现了关于npm的事。如果您想使用npm安装软件包,是否必须先下载该文件?如果是这样,你把文件放在哪里?你会把它放在与npm相同的文件夹中吗?
我尝试用npm安装faye,这就是我在npm-debug.log上的内容:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'faye' ]
2 info using npm@2.7.4
3 info using node@v0.12.2
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 silly cache add args [ 'faye', null ]
6 verbose cache add spec faye
7 silly cache add parsed spec { raw: 'faye',
7 silly cache add scope: null,
7 silly cache add name: 'faye',
7 silly cache add rawSpec: '',
7 silly cache add spec: '*',
7 silly cache add type: 'range' }
8 verbose addNamed faye@*
9 silly addNamed semver.valid null
10 silly addNamed semver.validRange *
11 silly addNameRange { name: 'faye', range: '*', hasData: false }
12 silly mapToRegistry name faye
13 silly mapToRegistry using default registry
14 silly mapToRegistry registry https://registry.npmjs.org/
15 silly mapToRegistry uri https://registry.npmjs.org/faye
16 verbose addNameRange registry:https://registry.npmjs.org/faye not in flight; fetching
17 verbose request uri https://registry.npmjs.org/faye
18 verbose request no auth needed
19 info attempt registry request try #1 at 7:19:45 PM
20 verbose request id e2cc452cb2788a4b
21 http request GET https://registry.npmjs.org/faye
22 info retry will retry, error on last attempt: Error: connect EACCES
23 info attempt registry request try #2 at 7:19:55 PM
24 http request GET https://registry.npmjs.org/faye
25 info retry will retry, error on last attempt: Error: connect EACCES
26 info attempt registry request try #3 at 7:20:55 PM
27 http request GET https://registry.npmjs.org/faye
28 verbose stack Error: connect EACCES
28 verbose stack at exports._errnoException (util.js:746:11)
28 verbose stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
29 verbose cwd C:\tito3
30 error Windows_NT 6.1.7601
31 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "faye"
32 error node v0.12.2
33 error npm v2.7.4
34 error code EACCES
35 error errno EACCES
36 error syscall connect
37 error Error: connect EACCES
37 error at exports._errnoException (util.js:746:11)
37 error at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
37 error { [Error: connect EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'connect' }
38 error Please try running this command again as root/Administrator.
39 verbose exit [ 1, true ]
答案 0 :(得分:2)
Npm将为您下载该模块的相关文件。
有两种使用npm安装节点模块的模式,无论是本地还是全局。本地(默认)表示模块下载到运行命令的位置的node_modules目录,因此您通常会在应用项目的根目录下运行它。全局(-g选项)表示它被下载到某个位置,因此系统上的任何内容都可以使用它.e grunt_cli
Windows上的程序文件目录受到保护,因此您需要以管理员身份运行该命令,或者从npm install
<等非保护路径运行c:\myapp
/ p>
您可能希望查看package.json文件,这是一个允许您列出应用程序所需的所有模块的文件。在包含package.json的位置只运行npm install
将导致npm读取文件并为您下载所有相关模块。