Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 1046 of the free egghead.io lessons, plus get JavaScript content delivered directly to your inbox!



Existing egghead members will not see this. Sign in.

Run builds on file changes using watch with npm scripts

0:55 JavaScript lesson by

We can set up a file watcher to compile automatically while we develop. In this lesson we wire up a new dev script to run the build script when source files change.

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

We can set up a file watcher to compile automatically while we develop. In this lesson we wire up a new dev script to run the build script when source files change.

Avatar
KMD A/S

I have an error while using npm run dev:

npm-package@1.0.0 dev C:\works\others\node.js\npm\create-npm-package

watch 'npm run build' src

Watching run
Watching build'
Watching src
C:\works\others\node.js\npm\create-npm-package\node_modules\watch\main.js:75
if (err) throw err;
^

Error: ENOENT: no such file or directory, stat 'C:\works\others\node.js\npm\create-npm-package\run'

npm ERR! Failed at the npm-package@1.0.0 dev script 'watch 'npm run build' src'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the npm-package package,
npm ERR! not with npm itself.

Node - 7.8.2
npm - 4.2.0

In reply to egghead.io
Avatar
Trevor

It may be an issue with the watch package on Windows. Try replacing this line https://github.com/trevordmiller/sensitive-words/blob/master/package.json#L7, with "dev": "babel src -d build --watch" and then run npm run dev again and let me know if that works :)

In reply to KMD A/S
Avatar
KMD A/S

This solution works for me :-) Thx a lot In meantime i installed npm-watch package that works without problem.

In reply to Trevor
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?