santosh kumar patro
santosh kumar patro

Reputation: 8201

How to manage npm install in a system without internet connection

I am facing challenges while creating package for all the clientside components of my project in a system which does not have internet connection (for windows).

I have installed NPM for windows in the system. I need to manage the node_modules and run gulp commands in the system to create the package.

Since there is no internet connection in the box, I decided to copy the node_modules from my local box to the box which does not have internet connection.

For copy task, I am using msbuild script but somehow it is not working for me. Also, I see that when I am trying to copy the node_modules manual from one folder to another folder I am unable to copy.

Installed Node version : v0.12.2 NPM version: 2.7.4

Can anyone help me to provide any working sample to fix the above problem.

Upvotes: 4

Views: 6032

Answers (1)

chriskelly
chriskelly

Reputation: 7736

I think your approach is generally sound. You can build on the internet connected computer no problem! Copy files over with a usb stick if you like.

Here are some tips that might help solve your problems.

  1. If the box is offline, develop on your local machine and deploy to the box
  2. If possible do the gulp steps also on your local machine
  3. Otherwise you need to run the local directory install of gulp. e.g.

    node node_modules\gulp\bin\gulp.js build
    

    because you won't be able to npm install -g gulp

  4. Point 3 will work for other global npm_modules too btw

  5. If you are facing long paths (> 256 characters) which can cause copy problems

    • Try using npm dedupe to remove duplicates
    • Or try copying to a shorter path e.g to c:\proj instead of to c:\very\long\path\proj
    • Or explicity install a dependency which has a long path

      e.g npm install [email protected]

      and then prune that folder from the original

      rm node_modules\package\node_modules\package_with_too_many_nested_folders

    • Or Install the latest npm (v3.0 or higher) which solves this issue once and for all

      e.g. npm install -g npm

      which will build a much flatter hierarchy for your packages. Requires removing and reinstalling all packages.

  6. Point 5 is a notorious issue on windows which is not a problem on linux because paths can be extremely long. (unless you are mounting a windows a windows directory from linux)

Personally I would go straight for the latest npm version but you have a number of ways of getting around the issue if this is not possible.

Upvotes: 2

Related Questions