How to configure "npm install" in Task Runner Explorer VS2015
Asked Answered
C

1

6

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?

Contrabandist answered 8/9, 2015 at 14:0 Comment(0)
N
5

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.

Nally answered 23/10, 2015 at 19:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.