nodejs on heroku commiting node_modules file path too long

I am new to nodejs and heroku and I am trying to deploy my first app.

having read this post Should I check in node_modules to git when creating a node.js app on Heroku? it seems that best practice is to commit the node_modules folder.

My problem is that I cannot commit some of the node_modules as the file path seems to be too long for git to manage. Has anyone else had this problem? I am using SourceTree as my Git GUI and running windows 7.

The error i get in sourcetree is:

git -c diff.mnemonicprefix=false -c core.quotepath=false rm -q -f -- node_modules/gulp-concat/node_modules/gulp-util/node_modules/lodash.template/node_modules/lodash.escape/node_modules/lodash._escapehtmlchar/node_modules/lodash._htmlescapes/index.js

fatal: pathspec 'node_modules/gulp-concat/node_modules/gulp-util/node_modules/lodash.template/node_modules/lodash.escape/node_modules/lodash._escapehtmlchar/node_modules/lodash._htmlescapes/index.js' did not match any files

Thanks

Contrury to the post, I would advice not to commit node_modules into the repository.

Reasons:

  1. Different platforms might build the modules differently. One can develop on windows and push to a linux server.

  2. You might have some of your modules installed globaly on the local machine. In that case they wan't be installed in node modues.

  3. There are modules that are used only during development, but not in production.

If you are woried about deployment speed to heroku, dont. Heroku caches all modules you use and updates only the changes.

Eather way the error you get is not becouse of a long file name. Its ether becose you try to do some operation on an untracked file. Or on tracked file that no longer exist.