From the course: Learning webpack 4

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using npm build scripts

Using npm build scripts

From the course: Learning webpack 4

Start my 1-month free trial

Using npm build scripts

- [Instructor] Let's add an npm script to our package JSON file. Here in the package JSON, under chapter one, chapter one six, under start, I'm going to change the test command to a new one called build. Now build is going to be set to webpack so that I can run npm run build anywhere inside of this project folder and it will run webpack for me. So nice little shortcut there. Let's give this a shot. I'm going to say npm run build and this should execute webpack. Perfect. Now if you get an error here that says webpack not found it's a pretty common error. Something you can do to fix this is you can find it directly in the node modules binary. So, let me show you what I mean by this. If we look at node modules, and then I look at this dot bin folder, there are all the executables for webpack in this folder. So you could dig it out of there by saying dot slash node underscore modules slash dot bin slash webpack. And again if I run npm run build, that's going to work as well. So, either…

Contents