1

I am using Node and Grunt to watch files and compile my stylus css preprocessor code. Node is otherwise not necessary for this project.

Right now the node_modules folder is not checked into my git repository which is fine for release. The problem I have is whenever I create a feature branch, node_modules is not there and I can't watch or compile my stylus files.

Is there a way for node_modules to appear in new branches without adding them to .git? I'd rather not do an npm install on every new branch.

Or is it best practice to add node_modules to git?

If I'd like to add them to git, should I add node_modules as a git submodule? If adding as a submodule, what url should be specified if any?

The best discussion I've seen about a similar situation is here.

Community
  • 1
  • 1
Bryan
  • 17,201
  • 24
  • 97
  • 123

1 Answers1

1

If you are not using npm actively, you don't have to do npm install on every new branch, you can just do it once, add node_modules folder to Git and commit the dependencies to the master (the same way they recommend for frontend dependencies and Bower).

I wouldn't recommend you adding node_modules as a submodule: usually a submodule is a somewhat self-sufficient component that should/can be developed separately, which is clearly not the case here.

bredikhin
  • 8,875
  • 3
  • 40
  • 44
  • Thanks. That's what I did. Also, since npm dependencies are managed by package.json, it doesn't make sense to create a submodule. – Bryan Jan 09 '14 at 19:26