npm start is the conventional command for launching a Node.js application through the start script configured in package.json. The script can hide the entry file, command-line arguments, and other startup details behind one project-independent command. section 2.6.7
Use the command as part of a predictable project startup workflow:
- Install dependencies with npm install; use npm install --omit=dev when preparing an environment that needs only production dependencies. section 2.6.7 section 10.5.1
- Run npm start from the project directory to invoke the command recorded under scripts.start in package.json. section 2.6.7 section 10.5.1
- Set required environment variables before retrying a service that reports missing configuration. section 10.5.1
A package-defined start command
A project can define "start": "node src/index.js" in package.json. After changing into the project directory and installing dependencies, run npm start without needing to remember the entry-file name. section 2.6.7
cd chapter-2/example-3 npm install npm start
Follow the compact project-directory workflow: change directory, install dependencies, and start the application. section 2.6.7
