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

- 875
- 1
- 11
- 17

- 1,335
- 2
- 9
- 17
6 Answers
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 :

- 1,499
- 1
- 10
- 17
-
2where I can find the bundled app? – noe Oct 16 '19 at 02:37
-
1after yarn build you can see the build folder inside your project, this folder contains the bundled app or compiled project. – noe Oct 16 '19 at 07:08
-
26Although I can't find it documented anywhere, I just ran `yarn build`, and it does work; it's perfectly valid shorthand for `yarn run build`. – charles-allen May 15 '20 at 07:04
-
`yarn build` works perfectly fine just like `yarn run build`, same is with `yarn dev` that also works fine just like `yarn run dev`, Although this is not mentioned at any place but they just works. – Ansub Sep 01 '22 at 04:18
"yarn build Bundles the app into static files for production." from Create React App by MAD9135.
https://mad9135.github.io/F2020/modules/week3/02-react-tooling/07-create-react-app.html

- 173
- 2
- 11
-
11Where did you read this? For me `yarn` does not understand such command. – akostadinov Sep 17 '20 at 11:29
-
It's apparently the output of [some command](https://mad9135.github.io/F2020/modules/week3/02-react-tooling/07-create-react-app.html). Also, please don't quote without telling where you got the quote. – General Grievance Sep 19 '22 at 14:02
yarn build
is a shortcut of yarn run build
from original documentation:
Reference: https://classic.yarnpkg.com/lang/en/docs/cli/run/#toc-yarn-run-script

- 106
- 1
- 1
- 7
its the same i guess the real difference between yarn and npm is the performance and security that yarn provides.
yarn actually installing packages in parallelly and Npm only install one package at a time
And Yarn have more secure dependency.

- 41
- 4
Yarn is a package manager for your code. Yarn build makes a bundle of apps in one format and shows errors if the app has any problem that will make an error on the server.

- 9
- 1
Note that in a yarn workspace, a yarn.build
key within package.json will be used by yarn build
from the root workspace and yarn run build
is required to run a locally defined scripts: { build: ... }
.

- 6,096
- 2
- 25
- 18