我正在尝试在未连接到网络的LAN上安装node.js.我已经安装了node.js没有问题,但看起来npm想要访问网络,
http GET https://registry.npmjs.org/moment
所以我无法安装我需要的模块。
以下是生成的npm-debug文件:
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 'moment',
1 verbose cli '-g' ]
2 info using npm@1.1.69
3 info using node@v0.8.16
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose read json C:\Documents and Settings\User.PALS-DADS\Application Data\npm\package.json
6 verbose read json C:\Documents and Settings\User.PALS-DADS\Application Data\npm\package.json
7 verbose cache add [ 'moment', null ]
8 silly cache add name=undefined spec="moment" args=["moment",null]
9 verbose parsed url { pathname: 'moment', path: 'moment', href: 'moment' }
10 silly lockFile b56def36-moment moment
11 verbose lock moment C:\Documents and Settings\User.PALS-DADS\Application Data\npm-cache\b56def36-moment.lock
12 silly lockFile b56def36-moment moment
13 verbose addNamed [ 'moment', '' ]
14 verbose addNamed [ null, '' ]
15 silly lockFile 42aa250a-moment moment@
16 verbose lock moment@ C:\Documents and Settings\User.PALS-DADS\Application Data\npm-cache\42aa250a-moment.lock
17 silly addNameRange { name: 'moment', range: '', hasData: false }
18 verbose url raw moment
19 verbose url resolving [ 'https://registry.npmjs.org/', './moment' ]
20 verbose url resolved https://registry.npmjs.org/moment
21 info trying registry request attempt 1 at 16:47:42
22 http GET https://registry.npmjs.org/moment
23 info retry will retry, error on last attempt: Error: getaddrinfo ENOENT
24 info trying registry request attempt 2 at 16:47:52
25 http GET https://registry.npmjs.org/moment
26 info retry will retry, error on last attempt: Error: getaddrinfo ENOENT
27 info trying registry request attempt 3 at 16:48:52
28 http GET https://registry.npmjs.org/moment
29 silly lockFile 42aa250a-moment moment@
30 error Error: getaddrinfo ENOENT
30 error at errnoException (dns.js:31:11)
30 error at Object.onanswer [as oncomplete] (dns.js:123:16)
31 error If you need help, you may report this log at:
31 error
31 error or email it to:
31 error
32 error System Windows_NT 5.1.2600
33 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "moment" "-g"
34 error cwd C:\Documents and Settings\User.PALS-DADS\Desktop
35 error node -v v0.8.16
36 error npm -v 1.1.69
37 error syscall getaddrinfo
38 error code ENOTFOUND
39 error errno ENOTFOUND
40 verbose exit [ 1, true ]
如何在不连接网络的情况下安装模块?
由于
答案 0 :(得分:4)
如果您查看the docs,您会看到只需将文件系统路径或URL传递给包含您要安装的软件包的tarball即可安装软件包。
npm install http://server.on.lan/moment.tgz
当然,如果有问题的软件包指定了任何依赖项,npm将尝试从Web上获取它们。时刻没有,所以你应该能够下载tarball并安装它。
但是,如果您要安装其他具有依赖关系的软件包,那么您的LAN上的setting up a npm registry mirror可能会更好。