Using gulp to build without installing npm

I work in a web application (JavaScript / C #, the version is controlled by TFS), and our team wants to start using Visual Studio 2015. Microsoft forces developers to use existing popular tools such as Gulp for automated tasks, so I wrote several Gulp tasks that will be executed on the server.

My problem is that our automated assemblies generate new project folders on the build server, so I cannot start gulp myBuildTaskwithout first starting npm install. Installing npm adds more than 2 minutes to the build process, and it seems very inefficient to download the same dependencies for each build (since they will rarely change).

Anyway, can I run the Gulp task in a new project folder without first starting npm install?

Parameters that I reviewed:

  • Include node_modules in TFS. I could not add the node_modules folder to TFS (which would cause it to exist in each new folder), since the nested dependencies are a file path that is too long for Windows. I could go this route without a conversation, but I'm not sure that I want all these files to be in my solution (most of which are not needed, for example, readme and test files).

  • Run npm install after each automatic build. As already mentioned, I do not want to do this because it adds a few minutes to the build process.

  • Install NPMs worldwide. I'm not sure if this is possible, but I wonder if I can install all the project dependencies globally on the build server (avoiding installation at the project level). My concern with this approach is that I do not want to manually update the build server with the NPM module installed each time we add the Gulp plugin.

Ideally, the solution would be something like # 3. The modules will be installed globally, but each assembly can run npm install, which will check each module. If a new npm module has been added to package.json, it will be loaded. This one npm installwill be quite fast, since in most cases all modules already exist (globally installed on the build server).

+4
1

, :

  • npm install . npm ( ) npm dedupe. dedupe , npm install. npm shrinkwrap, npm-shrinkwrap.json, "" , ( ) npm install.

  • , node_modules - , /rsync , npm install

  • Node node_modules, , (node_modules node_modules), node_modules , . , , -

:

my_project
    node_modules/
        dependency1
        dependency2
    build_001/ 
    build_002/
    build_00x/
        no node_modules here, 
        no deps here

, , , , . - , : :

my_project
    ver_af729b
        node_modules
        build_001
        build_002
    ver_82b5f3
        node_modules
        build_003
        build_004

af729b 82b5f3 () sha npm-shrinkwrap.json. , shrinkwrap , build script ver_something npm install . , , , .

------------------ -------------------

npm install ( , ), : npm install node_modules .

, node_modules node_modules - npm .

+2

Source: https://habr.com/ru/post/1623449/


All Articles