Module BasicsLesson 18Free preview
Node NPM Scripts
This lesson is part of Node.js · All levels
Summary
NPM scripts allow you to run long commands via a short alias in package.json. You can make a start, test, build, or dev script that calls other tools like tsc, jest, or nodemon. That way, the whole team uses the same command and doesn't have to memorize the configuration of the tool.
Key points
- Scripts are defined on the object scripts at package.json
- Npm run is the name of the script running; npm start and npm test are special aliases
- The script can run multiple commands at once with &&
- Use pre<script> and post<script> to hook before/after
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.