Question: how to npm scripts work?
Answer: Custom Scripts These are scripts with names that NPM recognizes and attaches special meaning to. For example, you can write a script called prepublish . NPM will execute the script before your package is packed and published, and also when you run npm install locally without any arguments. More on such scripts here.