You don't have to ask developers to install Bower and Grunt to start your app
It’s very common in font-end applications to have Bower dependencies and use Grunt (or Gulp) for their build system. Usually in README document it’s stated that you need to install Bower and Grunt globally before you can start the project.
In Swagger Editor project, I made this process as simple as git clone
and then npm start
.
No need for installing Bower or Grunt. It also works in Windows.
npm scripts to rescue!
With npm scripts we can remove dependencies to global installation of Bower and Grunt and also install npm and Bower packages automatically. First of all we need to install Bower and Grunt as developer dependencies of our app.
Now, using npm scripts fields we can define start
script to trigger npm install
, bower install
and then grunt serve
.
Now, git clone
and then npm start
will do everything you need. This will work perfectly in Linux, OS X and Windows because "start"
is simply a Bash script that uses ./node_moduels/.bin
as $PATH
. So even if user don’t have Gulp installed globally, gulp
command in your npm script will execute gulp
binary in ./node_modules/.bin
.
Pro tip: If you name your script, server.js
you don’t even have to have a start
field in scritps
of your package.json
, npm will automatically run node server.js
for npm start
command