Be the first user to complete this post

  • 0
Add to List

Configure The 'script' tag In package.json To Run Multiple Commands

You are probably used to using the scripts defined in your scripts tag to start your nodejs server if you're using nodemon. Turns out that the script tag can be a tad more useful than just that. For example, you can run multiple commands in a from a single script. e.g. Lets say we have a couple of grunt tasks

  • jsBuild: Concatenates and minifies our js files.
  • cssBuild: Concatenates and minifies our css files.
  • watch: Keeps an eye when any changes are made to our .js files and .css files and triggers a jsBuild and cssBuild.
To run tasks in parallel, simply seperate them with an & To run tasks sequentially simply seperate them with an &&
scripts: {
   buildAll: 'grunt jsBuild & grunt cssBuild'
Now you have the following commands at your disposal in the shell from your project's root Directory
npm run buildAll
npm run dev

Also Read:

  1. Understanding routers in express 4.0 - Visually
  2. Understanding semver versioning for your nodejs packages
  3. Setup passportjs for local authentication and authorization using expressjs
  4. Resolved - sudo npm command not found
  5. Unit test your Nodejs RESTful API using mocha
  6. Configuring jshint as a pre-commit hook for your nodejs applications
  7. How to publish a package on npm