4

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.

Rodmentou
  • 1,610
  • 3
  • 21
  • 39
santosh kumar patro
  • 7,231
  • 22
  • 71
  • 143

1 Answers1

2

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 deepdep@1.2.4

      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.

chriskelly
  • 7,526
  • 3
  • 32
  • 50
  • Thanks a lot for the details. For point 3 if I install gulp globally in my local system, then all the dependencies related to gulp are downloaded and placed in the fodler C:\Users\xxxxxxxx\AppData\Roaming\npm. But in case where the system is offline and I am trying to setup Continuous Integration of the gulp tasks which is executed using a service account instead of my own account where do the gulp related folders be placed. For point 5 if I update npm to the latest version does the copying of node_modules issue gets resolved. – santosh kumar patro Nov 13 '15 at 12:57
  • For point 3 you should also install gulp and its dependencies locally (you need to anyway!). Install with ```npm install gulp-whatever --save-dev```. I don't see how service account would make a difference you can just run everything from the npm root folder. npm projects don't need global dependicies (unlike other package managers) – chriskelly Nov 13 '15 at 13:30
  • For point 5: If it's long path related (which I suspect) then yes. – chriskelly Nov 13 '15 at 13:31