简体   繁体   中英

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

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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM