Is yarn run
intended to be the equivalent of npm start
?
4 Answers
It seems yarn run start
is the equivalent of npm start
, which runs the script inside the start
field of the script
field in package.json

- 7,313
- 5
- 29
- 46
Few things to understand:
npm: run command is mandatory to execute user defined scripts.
yarn: run command is not mandatory to execute user defined scripts.
start command is not a user defined script name, so you may not need to specify run command to execute it.
So, all the below commands work similar!
npm start
npm run start
yarn start
yarn run start
If you have a user defined script named 'app':
npm app
(Does not work!)npm run app
(Works!)yarn app
(Works!)yarn run app
(Works!)
Note: By default start runs node server.js in case not explicitly defined.

- 5,100
- 13
- 43
- 62

- 777
- 6
- 6
-
-
Default behaviour is also mentioned in the doc similarly https://docs.npmjs.com/cli/start.html – Chandrashekhar Naik Jan 13 '20 at 08:34
-
**run** is not required for `yarn run` unless the script's name is the same a yarn sub-command (e.g. "run" would need `yarn run run` which is weird and might want to be avoided). – Kevin Jun 10 '20 at 17:39
npm start
is a shortcut for npm run start
Now in terms of running scripts from package.json
, all these are equivalent:
npm run start
npm start
yarn run start
yarn start
npm run myscript
npm myscript
this is an error
yarn run myscript
yarn myscript
This is because run
is not mandatory command for yarn
, but it is for npm
.
Bonus
npr start
- OK
npr myscript
- OK
Put this file somewhere in PATH
, eg. %localappdata%\Programs\Git\cmd
npr.cmd
npm run %*

- 29,062
- 22
- 108
- 136
yarn run
is similar to npm run
, they can be used to run the scripts in package.json
.
For npm, you can leave out run
when run the npm lifecycle scripts (test
, start
, restart
, and stop
), but these scripts maybe have extra effect. For example, npm start
will run node server.js
if the "scripts" object does not define a "start" property in package.json
. see the doc npm run. You can't run script with other name leaving out run
.
For yarn, you can leave out run
for all the scripts in package.json
, but if your script name is same as yarn built-in cli commands, the built-in cli commands will have preference over your scripts. doc yarn run.
So the best way to run scripts in package.json: never leave out run
.

- 369
- 5
- 8