What does " yarn build " command do? Are " npm build " and "yarn build" similar commands?

sudipt dabral picture sudipt dabral · Feb 14, 2019 · Viewed 58.2k times · Source

What does yarn build command do ? Are yarn build and npm build the same? If not what's the difference?

Answer

jtouzy picture jtouzy · Feb 14, 2019

yarn build and npm build are not existing commands by default. I think you mean yarn run build or npm run build.

build is a command which can be specified in your package.json file on the scripts property. See the example below.

{
    "name": "mypackage",
    "version": "0.1.0",
    "scripts": {
       "build": "webpack --config webpack.dev.js"
    }
}

In this example, build is a shortcut for launching command webpack --config webpack.dev.js. You can use every keyword you want to define some shortcuts to launch commands.

And the only difference between the two commands it's the JS dependency manager you're using, yarn or npm.

More infos :

https://yarnpkg.com/lang/en/

https://www.npmjs.com/