Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why recommend to commit node_modules for deployment? #622

Closed
manast opened this issue Aug 7, 2014 · 12 comments
Closed

Why recommend to commit node_modules for deployment? #622

manast opened this issue Aug 7, 2014 · 12 comments

Comments

@manast
Copy link

@manast manast commented Aug 7, 2014

I think this is a big mistake, will cause more problems that it solves, why not use npm shrinkwrap instead which does the same but without needing to commit a lot of unnecessary code to git?

https://www.npmjs.org/doc/cli/npm-shrinkwrap.html

@rlidwka
Copy link
Collaborator

@rlidwka rlidwka commented Aug 7, 2014

Sometimes it is a mistake, sometimes it is not, it depends on your workflow really.

@manast
Copy link
Author

@manast manast commented Aug 7, 2014

could you describe a workflow where you need to commit node_modules and shrinkwrap would not work?

@rlidwka
Copy link
Collaborator

@rlidwka rlidwka commented Aug 7, 2014

git bisect ?

@manast
Copy link
Author

@manast manast commented Aug 7, 2014

what does that mean? :)

@rlidwka
Copy link
Collaborator

@rlidwka rlidwka commented Aug 7, 2014

Well it is one of the major advantages of having node_modules checked in.

@manast
Copy link
Author

@manast manast commented Aug 7, 2014

sure, but can you explain when do you use git bisect, and what problems does it solve?

@rlidwka
Copy link
Collaborator

@rlidwka rlidwka commented Aug 7, 2014

This isn't really the place to discuss this, since it has nothing to do with pm2. Here is one opinion about it that makes sense: http://www.futurealoof.com/posts/nodemodules-in-git.html

It should probably be removed/changed in README though, because it's not "best practice", it's just one of possible setups.

@manast
Copy link
Author

@manast manast commented Aug 7, 2014

I think this is a legitimate issue since pm2 supports deployment now. The post you mentioned is from 2011 when npm shrinkwrap was not available.

@soyuka soyuka closed this in 3b3bf8e Aug 10, 2014
@Unitech
Copy link
Owner

@Unitech Unitech commented Aug 10, 2014

Embedding dependencies make your app more independent.
I totally agree that npm shrinkwrap is a good solution but if you use that with pm2-deploy add the npm install command on the post-deploy hook.

"post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production"
@manast
Copy link
Author

@manast manast commented Aug 10, 2014

In my experience committing dependencies may work if you are the only developer on an app, as soon as there are several it becomes problematic, you really don't want to handle merge conflicts on the modules you depend on. This problems grows exponentially with the amount of developers working simultaneously...

@manast
Copy link
Author

@manast manast commented Aug 10, 2014

@Unitech good tip, maybe you could add it to the README as well?

soyuka added a commit that referenced this issue Aug 10, 2014
@LoicMahieu
Copy link
Contributor

@LoicMahieu LoicMahieu commented Aug 11, 2014

In our deployment process, we commit node_modules and other files generated from the build in a separate production branch and we push it to a separate repositories (all team members don't have access to production repos, Gitlab handle that perfectly ❤️ ! )
In production servers, just a git checkout and npm rebuild and your app is ready to be started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.