1

I have a Team Foundation Build server behind a firewall, and I would like to check in a node_modules/ directory (powering both a Browserify client app and Node server app) associated with a project so that all of the files and dependencies needed to deploy a build are available without fetching anything.

Checking node_modules/ in to TFS seemed to work at first, except that the bin/ directories appearing in around 20 of my NPM dependencies were not checked in. bin/ does not appear in my .tfignore (or anywhere else I know of that could be preventing the check in).

These bin/ directories don't appear in the included/excluded changes in Team Explorer, at all. It's possible to locate one of these folders in Windows Explorer and add it with the TFS context menu, but doing that for all of the dependencies would be horrifically tedious and error prone.

How can I persuade TFS to detect changes in these folders? Is there some other configuration affecting included/excluded changes that I'm not aware of?

Pathogen
  • 845
  • 11
  • 16
  • A mostly usable workaround: using the TFS add context menu item on the node_modules folder itself picks up every absent bin folder. Would still like to know where this is configured! – Pathogen Feb 16 '17 at 19:26
  • Have you installed any VS extension in your dev machine which may block the check in? – PatrickLu-MSFT Feb 17 '17 at 07:51

3 Answers3

2

It is not recommended to upload "bin" folder or "node_modules" folder into Version Control. But if you do want to do this, following the steps below:

  1. Go to "C:\Users\youraccount\AppData\Local\Microsoft\Team Foundation\x.0\Configuration\VersionControl" folder and open "LocalItemExclusions.config" file. (There may several folders named like 1.0, 2.0, 3.0, you need to make sure open the folder your VS current use.)

  2. Delete the lines like following and save the file:

  <Exclusion>bin</Exclusion>
  <Exclusion>*.dll</Exclusion>
  1. Close Visual Studio.
  2. Delete "node_modules" folder.
  3. Restart Visual Studio.
  4. Run "npm install" command to reinstall the node modules.
  5. Check "Pending Changes", files in "bin" folder should be listed in "Excluded Changes" section.
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • Works as described. My node modules have no DLL files though (and I will avoid checking in actual build products), the `bin` directories only contain scripts. – Pathogen Mar 03 '17 at 18:26
0

To check if the files and bin folders will get ignored by TFS. You could try to manually add them (such as drag to source control explorer). If you couldn't, then must related to some .tfignore settings , you may double check this such as if there is a .tfignore file in the root of the project folder level.

If you could, there maybe something wrong with your workspace or source control mapping of the bin folder. Try to remove the source control bindings and rebinding to TFS. Also give a try with delete the old workspace and use a new workspace.

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Dragging a folder to source control explorer works, the contents of folders named `bin` appear under `excluded items` and can be included. But, if I do not do this, contents of `bin` are not detected Team Explorer > Pending Changes. I have a `.tfignore` at solution level, there is nothing related to `bin` in it. – Pathogen Feb 17 '17 at 18:24
  • I'm afraid `Bin` folders should already be ignored by TFS which are not under source control. The changes definitely will not shown in pending changes. Well, you need to manually add the bin folders to source control first time. And delete the files in the workspace(check in pending changes and mark a back up) then pull down the latest version which may do the trick(create a new correct source control mapping) .Or directly use a new workspace and delete the old one. – PatrickLu-MSFT Feb 20 '17 at 03:25
  • Besides, usually we do not suggest add the BIN and the OBJ folders to source control, but do add the 3rd party dll's or using nuget package to handle them. Basically all that you need as input for your application is in source control, but the output of you application (the created dll's, pdb's etc) should not be included. – PatrickLu-MSFT Feb 20 '17 at 03:26
-1

You shouldn't check in node_modules - ever.

  1. Rather use browserify or WebPack (I'd recommend WebPack) to package up your bundle.js.
  2. Add the bundle.js to your source/scripts folder. Reference your bundle.js from your html instead of any <../node_modules/../scripts>.
  3. Remove the npm install from your build script. you won't need it now due to referencing your bundle.js

WebPack is a dev-step, but it secures the version of packages you used during development and also saves you the npm install headache during deployment.

Neville
  • 545
  • 1
  • 4
  • 19
  • 1
    I am using Browserify for my client side code. But I specifically need to run a node application, which includes a bunch of content that can't be added to a bundle. – Pathogen Apr 19 '17 at 21:33
  • 1
    As misguided as it is to check node_modules into source control, the OP's issue with a firewalled build server being unable to dynamically pull NPM dependencies is valid. I'm in the same boat, with a legacy build system that does not include anything like Browserify or Webpack--it's actually a seriously backwards homebrewed build system that controls millions of lines of code, and would make you cry if you saw it. Because of this, I *must* check in my node_modules folder. Simply saying, "don't do that" isn't a useful comment. – Artif3x Feb 20 '18 at 14:59