Using npm scripts
npm scripts are commands that we can define in the package.json
file. These commands can be executed using the run
command:
# npm run <script-name> npm run lint
This is great because we can define our own commands and we can use them to automate tasks. For example, we can define a command to run the linter in our project:
{ "scripts": { "lint": "standard", "lint:fix": "standard --fix" }, "devDependencies": { "standard": "^12.0.1" } }
Then we can run the following command:
npm run lint npm run lint:fix
npm scripts are basically shortcuts to run commands that we can run manually in the terminal. So, you can build quite complex things...