install a package on an offline pc with npm

2,185 views
Skip to first unread message

NodeNinja

unread,
Feb 10, 2015, 12:50:22 PM2/10/15
to nod...@googlegroups.com
I am trying to install a nodejs package on a offline pc (no internet connection) but I'm having trouble doing so

I have the package folder and its dependencies  I need to install on the offline pc

so on the offline pc i do

C:\>npm install --global --cache d:\nodejs\npm-cache --optional --cache-min 99999 enclose
npm http GET https://registry.npmjs.org/enclose
npm http GET https://registry.npmjs.org/enclose
npm http GET https://registry.npmjs.org/enclose
npm ERR! Error: getaddrinfo ENOENT
npm ERR!     at errnoException (dns.js:31:11)
npm ERR!     at Object.onanswer [as oncomplete] (dns.js:123:16)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <np...@googlegroups.com>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--global" "--cache" "d:\\nod
ejs\\npm-cache" "--optional" "--cache-min" "99999" "enclose"
npm ERR! cwd C:\
npm ERR! node -v v0.8.12
npm ERR! npm -v 1.1.63
npm ERR! syscall getaddrinfo
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\npm-debug.log
npm ERR! not ok code 0

and I'm getting a whole list of errors as above
All the package folders and dependencies are in D:\nodejs\npm-cache
and I have also done
npm config set cache D:\nodejs\npm-cache

but to no avail.


Aria Stewart

unread,
Feb 10, 2015, 2:42:48 PM2/10/15
to nod...@googlegroups.com

> On Feb 10, 2015, at 12:50 PM, NodeNinja <aeon...@gmail.com> wrote:
>
> I am trying to install a nodejs package on a offline pc (no internet connection) but I'm having trouble doing so
>
> I have the package folder and its dependencies I need to install on the offline pc
>
> so on the offline pc i do
>
> C:\>npm install --global --cache d:\nodejs\npm-cache --optional --cache-min 99999 enclose
> npm http GET https://registry.npmjs.org/enclose
> npm http GET https://registry.npmjs.org/enclose
> npm http GET https://registry.npmjs.org/enclose
> npm ERR! Error: getaddrinfo ENOENT

npm doesn't operate offline, so it's always going to look for the registry.
>
> npm ERR! node -v v0.8.12
> npm ERR! npm -v 1.1.63

In addition, this is ancient. npm 1.1 won't work with the current registry, and node 0.8 is EOL. Consider upgrading to 0.12 or at least 0.10!

Aria

NodeNinja

unread,
Feb 10, 2015, 10:14:27 PM2/10/15
to nod...@googlegroups.com
After I upgrade to node version 0.10 will npm work offline.
I found a few posts on the internet where npm used the offline cache and didn't connect to the registry.

Aria Stewart

unread,
Feb 10, 2015, 10:24:54 PM2/10/15
to nod...@googlegroups.com

> On 10 Feb 2015, at 22:14, NodeNinja <aeon...@gmail.com> wrote:
>
> After I upgrade to node version 0.10 will npm work offline.

Sadly not. It is not (yet) designed to have that option.

> I found a few posts on the internet where npm used the offline cache and didn't connect to the registry.

YMMV! Might be possible to hack up the internals enough via config flags on the command line, but if it breaks you get to keep both pieces.


Aria

NodeNinja

unread,
Feb 10, 2015, 10:41:15 PM2/10/15
to nod...@googlegroups.com
I have seen cases on the internet where they download the tarball of the package on the internet pc and then transfer it to the offline pc and run npm on the tarball and many people have had success with it but when I try to do it npm tries to connect to the internet.

Aria Stewart

unread,
Feb 10, 2015, 11:54:44 PM2/10/15
to nod...@googlegroups.com

> On 10 Feb 2015, at 22:41, NodeNinja <aeon...@gmail.com> wrote:
>
> I have seen cases on the internet where they download the tarball of the package on the internet pc and then transfer it to the offline pc and run npm on the tarball and many people have had success with it but when I try to do it npm tries to connect to the internet.


Yeah, if all the dependencies are bundled, or the package has no dependencies, I could see that working. But it would require that.

zladuric

unread,
Feb 12, 2015, 2:29:23 AM2/12/15
to nod...@googlegroups.com
If you have npm 2+, I think `npm link` would work.

Download the package, offload it something, like /opt/npm/my-package.
Add it to dependencies ("my-package": "1.0.0")
Then npm link to that package (`npm link /opt/npm/my-package).

Reply all
Reply to author
Forward
0 new messages