Skip to main content

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 dev

Exception

For a script named start, you can skip run:

bash
npm start

Summary: scripts from package.json are run via npm run <script-name>, and npm start is a shorthand for start.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.