Is yarn run intended to be the equivalent of npm start?
The main difference between NPM and Yarn is the package installation process. Yarn installs packages in parallel. Yarn is optimized to fetch and install multiple packages at once. NPM will perform a serial installation process.
npm start is the short form for npm run start . So, its one and the same thing. Show activity on this post.
The yarn run command is used to run a script that you defined in the script section of your package. json file. When there is a defined script object in your package, running this command will run the specified [script].
'npm start' is used for executing a startup script without typing its execution command.
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
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 startnpm run startyarn startyarn run startIf 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.
npm start is a shortcut for npm run start
Now in terms of running scripts from package.json, all these are equivalent:
npm run startnpm startyarn run startyarn start
npm run myscriptnpm myscript this is an erroryarn run myscriptyarn myscript
This is because run is not mandatory command for yarn, but it is for npm.
npr start - OKnpr myscript - OK
Put this file somewhere in PATH, eg. %localappdata%\Programs\Git\cmd
npr.cmd
npm run %*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With