You can use npm-cache as an alternative way if you use built-in agents in place for assembly.
This is useful for build processes that run [npm | bower | composer | jspm] install each time as part of the build process. Since dependencies often do not change, this often means slower build time. The NPM cache helps resolve this problem by caching previously installed build machine dependencies. npm-cache can be a drop-down replacement for any build script that runs [npm | bower | composer | jspm] install.
How it works
When you run npm-cache install [npm | bower | jspm | composer], first looks for package.json, bower.json or composer.json in the current working directory, depending on which dependency manager is requested. Then it computes the MD5 hash of the configuration file and looks for a file named .tar.gz in the cache directory ($ HOME / .package_cache by default). If the file does not exist, npm-cache uses the installed dependency manager to install the dependencies. Once dependencies are installed, npm-cache tars recently loaded dependencies and saves them in the cache directory. The next time npm-cache launches and sees the same configuration file, it will find the tarball in the cache directory and unlock the dependencies in the current working directory.
And you can also try npm-install-missing .
However, if you use the VSTS Hosted Build Agent, then you cannot do this, because every time you queue the build with the Hosted Build Agent, a clean build agent is assigned to build. This means that the dependency package is not installed on the agent. You need to complete a full npm installation.
source share