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

feature: new core task for automatically running npm update/install #569

Closed
jokeyrhyme opened this issue Dec 12, 2012 · 7 comments
Closed

Comments

@jokeyrhyme
Copy link

If this is already possible then please tell me how (it's very hard to find anything specific if you just search for "grunt task npm update"). :P

It would be terrific if grunt could be configured to automatically run npm install and perhaps even npm update. I'm not sure what sort of smarts or options we'd need to stop it from running on every single build, but it definitely needs to happen at least once.

This can't really be done as a grunt plugin, because then it would need the developer to run npm update which defeats the purpose of this request.

This would facilitate the easy use of grunt plugins, without the extra step (provided package.json is properly defined).

proposed behaviour

  • if node_modules directory does not exist, run npm install
  • if modules in packages.json->dependencies are missing from node_modules, run npm install

I'm not sure when it would be best to run npm update, maybe have a task option that lets the developer choose the frequency or something?

@shama
Copy link
Member

shama commented Dec 12, 2012

-1 npm is the single greatest thing in node.js, imho. I think it would be irresponsible for Grunt to magic away npm. It's so easy to just type npm install. It is my opinion that if you or other devs are on a setup where npm install can not be easily typed then node_modules should be committed into the repo. My two cents.

@jokeyrhyme
Copy link
Author

I agree that npm install is / should be easy enough for most people.

However, I try to keep The Joel Test in mind when working on projects, and number 2 is:

Can you make a build in one step?

npm install and then grunt is 2 steps. If I have to make a makefile just so I can make this 1 step, then why would I even use grunt in the first place?

@tkellen
Copy link
Member

tkellen commented Dec 12, 2012

I don't like the idea of it happening magically behind the scenes, but can see it being helpful to mention that npm install is neeeded if node_modules is missing when Gruntfile.js/package.json are present. Also, this issue really belongs on the grunt-cli repo.

@sindresorhus
Copy link
Member

We should mention it to the user, have heard complaint about that before, but we should never do it automagically.

@cowboy
Copy link
Member

cowboy commented Dec 12, 2012

There are a few reasons I'm against this idea.

  1. Grunt is not a dependency management system. It shouldn't be responsible for doing that. It's a task running build tool.
  2. The user should learn how to use npm. It's not just a tool that installs development dependencies (for grunt), but it's also used to install project dependencies, something that grunt doesn't know or care about.
  3. Npm has a lot of really weird, seemingly random, issues. Having grunt run npm commands would certainly increase the number of npm-related issues filed against grunt projects.

@toddhgardner
Copy link

This is not grunt's job--Grunt is not an "all purpose" build engine, just a web/javascript build engine. Orchestrate npm, grunt, and anything else you want to do behind a shell/batch script to get to "build in one step" if you need it.

@rexmortus
Copy link

Fair enough.

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

No branches or pull requests

7 participants