Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure "npm install" in Task Runner Explorer VS2015

I have a problem with the node_modules folder created by npm.

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

A solution was to install npm@3 as it has the --flat parameter which flattens the folder. This is good.

Now I am using Task Runner Explorer in VS2015. Default it npm to install modules without the "--flat" option. The result is that I cannot publish the web project because the path exceeds the limit (even when the node_modules folder is added to ExcludeFoldersFromDeployment property in the project file), the error message is:

The "CollectFilesinFolder" task failed unexpectedly

A solution is to manually call npm install --flat but than my co-workers will have the same problem (and I am not talking about getting the folder removed from the file system :-/).

Is there a way to configure the parameters of the npm install, either by configuring Taks Runner Explorer or maybe in the package.json?

like image 507
bvanm Avatar asked Sep 08 '15 14:09

bvanm


1 Answers

Per the current NPM documentation (v3.3.9), npm install doesn't have a --flat command-line option. As far as I can tell, NPM v3 always installs modules in a flat directory structure (you can tell by doing a command-line install).

To ensure Visual Studio runs its commands with your version of node/npm, you will need to:

  • Install that version of npm. For example: cd C:\path\to\nodejs\ && npm install npm@3
  • Customize the External Web Tools paths. For example, move $(PATH) above all the $(DevEnvDir)... options.

As a sanity-check, open the Interactive Node window and execute .npm version. It should output an object with an "npm" property that equals npm --version.

You should now be able to NPM-install inside Visual Studio using npm @3.

like image 187
EthanB Avatar answered Oct 23 '22 05:10

EthanB