Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code: How to exclude folders from npm task auto-detection?

Visual Studio Code shows configured and auto-detected tasks in its Run Tasks menu. I would like to exclude the bin folder and all its subfolders from the npm task auto-detection. The npm.exclude setting appears to be designed for that purpose, but I haven't found how to use it.

I tried the following variations, with no success:

"npm.exclude": "**/bin"
"npm.exclude": "**/bin/"
"npm.exclude": "./bin"
"npm.exclude": "./bin/"
"npm.exclude": "**/bin/*.*"
"npm.exclude": "./bin/*.*"
"npm.exclude": ["**/bin"]
"npm.exclude": ["**/bin/"]
"npm.exclude": ["./bin"]
"npm.exclude": ["./bin/"]
"npm.exclude": ["**/bin/*.*"]
"npm.exclude": ["./bin/*.*"]

The syntax used for files.exclude and search.exclude doesn't appear to be allowed:

"files.exclude": {
     "**/.git": true,
     "**/.svn": true,
     "**/.hg": true
 }

What is the appropriate syntax for the npm.exclude setting?

like image 431
ConnorsFan Avatar asked Apr 04 '18 19:04

ConnorsFan


People also ask

How do you ignore a folder in VS Code?

To exclude a folder, go to File > Preferences, and search for file. exclude in the search settings. You can add the pattern of the folder you don't want Visual Studio Code to open.

How do I change the directory in VS Code?

You can go to that specific directory or create shortcut to desktop then click right click on that folder and then click on open with code. If you didnot see open with code then reinstall your VS code and check on open with code when you are reinstalling VS Code.

How do I create a .VS Code folder?

The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder. Once a root folder is added, the Explorer will show the new folder as a root in the File Explorer. You can right-click on any of the root folders and use the context menu to add or remove folders.


2 Answers

"npm.exclude" requires a "string and uses glob. So, my settings for npm.exclude, with multiple rules:

"npm.exclude": "**/@(vendor|node_modules|bower_components|dist|static)/**"
like image 128
Felipe Podestá Avatar answered Sep 17 '22 23:09

Felipe Podestá


Try (in your settings.json)

"npm.exclude": "**/bin/**"

that works for me to exclude scripts in workspaceFolder/bin/package.json

like image 40
Mark Avatar answered Sep 21 '22 23:09

Mark