0

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

Community
  • 1
  • 1
Code Pharaoh
  • 3,044
  • 2
  • 22
  • 26
  • So in order to try and get the paths issue resolved i moved my entire repo further up towards the root directory, i reinstalled my modules and then commited to a brand new app. The commit seemed to work correctly and everything was pushed online. however when i start my app i get "Error: Cannot find module 'Lodash._basebind". – Code Pharaoh Aug 29 '14 at 10:58
  • SO now i am going through and manually adding each module it says it cant find, everytime i install and commit a new module it says it cant find a different one. very very confused. – Code Pharaoh Aug 29 '14 at 11:24

1 Answers1

0

Contrary 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 won't be installed in node modules.

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

If you are worried about deployment speed to heroku, don't be. Heroku caches all modules you use and updates only the changes.

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

The Once-ler
  • 220
  • 3
  • 16
Max
  • 368
  • 3
  • 10
  • hey thanks for your reply. regarding the committing of the node_modules I found that before i committed them i was getting errors that suggested that modules where not being found. Is there something I should do to make heroku load in all the dependencies? Secondly regarding the Git error I think that it cant find the file because the path is too long. the file is definitely there and when i try to commit it directly from the command line i get a path length error. – Code Pharaoh Aug 28 '14 at 12:21
  • Maybe not all of your modules are in package.json – Max Aug 30 '14 at 17:10
  • yeah that may have been the case but then it seemed to be all references to modules that have internal dependancies i.e. lodash etc. – Code Pharaoh Aug 31 '14 at 09:26