2

I am trying to install node.js on a LAN that is not connected to the web. I've installed node.js with no problems, but it appears that npm wants to go out to the web,

  http GET https://registry.npmjs.org/moment 
so I can't install the modules that I need.

Here is the npm-debug file that is produced:

 
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 ]
 

How can I install modules without connecting to the net?

Thanks

4

1 に答える 1

4

If you take a look at the docs, you'll see that you can install packages by simply passing a filesystem path or URL to a tarball that contains the package you want to install.

npm install http://server.on.lan/moment.tgz

Of course, if the package in question specifies any dependencies, npm will try to fetch them from the web. moment doesn't have any, so you should be able to just download the tarball and install it.

However, if you want to install other packages which do have dependencies, you might be better off setting up a npm registry mirror on your LAN.

于 2012-12-27T17:35:19.437 に答える