Node.js deployment -- npm or gulp

by FrozenHeart   Last Updated August 21, 2016 08:03 AM

Suppose that I have a project written in JS via such frameworks like Node.js and Express. It also uses Mocha as a test framework and Gulp as a build system.

I wonder what is the best way to expose installation, testing and deployment to users.

I mean, users typically have to do the following stuff:

  • Install Node.js and npm
  • Install dependencies (npm, bower etc)
  • Preprocess CSS / JS (e.g. Sass, Less etc), minify images etc
  • Run tests
  • Run application

Which of these tasks should be handled via build system (in this case Gulp) and which by npm?

I guess there are two ways:

  • Do all stuff via Gulp. gulp install will install all npm and bower dependencies, gulp preprocess will preprocess CSS / JS / images, gulp test will run Mocha etc. Anyway, npm start should be handled separately because running a web-server is not a typical build system's task.
  • Force user to do all stuff via npm commands like this:


  "scripts": {
    "ins": "npm install && bower install && gulp preprocess",
    "test": "gulp test",
    "start": "node --harmony server.js",
    "deploy": "npm run ins && gulp --harmony"

Yeah, it uses gulp under the hood anyway but it's hidden from user so it looks like he uses npm only. I think that it's cool to limit user to npm, so they doesn't have to know anything about additional tool, and we can switch to another build system anytime later w/o rewriting deployment process manual.

What do you think? Is there any best practices related to this problem?

Related Questions

Python build system

Updated May 20, 2016 08:02 AM

Redis connection failing

Updated June 24, 2016 08:02 AM