codeomnitrix
codeomnitrix

Reputation: 4249

npm install package from local folder

I am behind a firewall and I believe git connection at 9418 are getting blocked. So I want to install a repository via npm (mysam https://github.com/mysamai/mysam). I tried installing directly with

npm --proxy <proxy-details> install -g mysam

Which fails saying -

fatal: Unable to look up github.com (port 9418) (No such host is known. )

So to avoid that I downloaded zip of the git repository and found on internet to use

cd package-folder

npm link

However that also fails stating same error. Is there any option to install the locally downloaded repository.

Thanks

Upvotes: 1

Views: 1098

Answers (1)

BetaRide
BetaRide

Reputation: 16844

Using npm without an internet connection just does not work.

This is how we worked around this for a fully isolated node project:

  1. You need a machine with internect connection. On this machine you do all the npm install calls.
  2. Getting the installed files to other machines is easy if you are on linux or mac. With windows you are likely to have problems with long path names. Windows can handle them internally but almos all tools including windows explorer, winzip, 7-zip and friends cannot handle them. You have to use either robocopy or put everything into a git repo to move them arround. For GIT check https://stackoverflow.com/a/26111092/671639 to make it handle long path names on Windows. Also add the node_modles/**/bin/** folder to .gitignore.
  3. We used GIT and moved around the repo. Attaching it as a remote allows to pull in new installed modules to the closed system.
  4. Once the new module is available in your closed system call npm rebuild to make sure you have all the tooling availbable.

Of course this means to add node_modules to GIT or whatever SCM you are using.

Upvotes: 1

Related Questions