start, actually defaults to node server.js, so the above declaration is
redundant. In order for the test command to work with mocha, I also need to
include it in the devDependencies section (it works in the dependencies
section also, but since it is not needed in production it is better to declare
it here).

The reason the above test command, mocha --reporter spec test, works is
because npm looks for binaries inside node_modules/.bin and when mocha was
installed it installed mocha into this directory.

The code that describes what will be installed into the bin directory is
defined in mocha's
package.json
and it looks like this:

The above code must be invoked with npm run watch-test, npm watch-test will
fail.

Running Binaries Directly

All the above examples consists of running scripts that are declared in
package.json but this is not required. Any of the commands in
node_modules/.bin can be invoked with npm run. This means that I can invoke
mocha by running npm run mocha directly instead of running it with mocha
test.

Code Completion

With a lot of modules providing commands it can be difficult to remember what
all of them are. Wouldn't it be nice if we could have some command completion
to help us out? It turns out we can! npm follows the superb practice of
providing its own command completion. By running the command npm completion
we get a completion script that we can source to get completion for all the
normal npm commands including completion for npm run. Awesome!

I usually put each of my completion script into their own file which I invoke
from .bashrc.

Combining Commands

The above features gets us a long way but sometimes we want to do more than one
thing at a time. It turns out that npm supports this too. npm runs the
scripts by passing the line to sh. This allows us to combine commands just as
we can do on the command line.

Piping

Lets say that I want to use browserify to pack my Javascript files into a bundle
and then I want to minify the bundle with uglifyjs. I can do this by piping
(|) the output from browserify into uglifyjs. Simple as pie!

The above scripts contain a few interesting things. First of all watch uses
&amp; to run three watch jobs concurrently. When the command is killed, by
pressing Ctrl-C, all the jobs are killed, since they are all run with the
same parent process.

watchify is a way to run browserify in watch mode. watch-server uses
nodemon in the standard way and restarts the server whenever a relevant file
has changed.

watch-less users nodemon in a less well-known way. It runs a script when
any of the less-files changes and compiles them into CSS by running
npm run build-less. Please note that the option --ext less is required for
this to work. --exec is the option that allows nodemon to run external
commands.

Complex Scripts

For more complex scripts I prefer to write them in Bash, but I usually include
a declaration in package.json to run the command. Here, for example, is a
small script that deploys the compiled assets to Heroku by adding them to a
deploy branch and pushing that branch to Heroku.

@Bran, I see what you are saying, but in this case it is scripts that are helping out during development. If the script needed to be run during install I would agree, but for development purposes I am in favor of doing what is needed to get the job done. If someone would like to develop on Windows they are free to add their own script tasks.

Not all transcription services work within the same industries. Discover a few of the more popular types of transcription services and what type of projects they typically include. See more script doctoring