How do you run a script by name?
To run a script by name, you use the command:
bash
npm run <script-name>Example
If package.json has:
json
"scripts": {
"build": "webpack",
"dev": "vite"
}then you can run them like this:
bash
npm run build
npm run devException
For a script named start, you can skip run:
bash
npm startSummary: scripts from package.json are run via npm run <script-name>, and npm start is a shorthand for start.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.