/ Wordpress

Roots Sage 9.0.0 - error Command failed with exit code 2

During assets compilation with yarn start, yarn build or npm run build you may run into this error:

error Command failed with exit code 2

sage error command failed with exit code 2


In order to fix it try to open the website and check browser console. There should be some JS/CSS error listed (marked with red color).
The message should be descriptive enough to give you an idea about possible solutions.

sage error in developer console

Unfortunately, such errors may also occur during the yarn start or npm start command execution and you will not get any message. So if your theme doesn't work after yarn start you should execute yarn build in order to look for (building) errors.

It is also a good idea to run yarn lint sometimes in order to avoid linting error messages during assets building.

Above instructions are valid for Sage 9.0.0-beta.4, but other 9.x versions would probably behave in a similar way.


In order to get error reporting back to the console edit resources/assets/build/webpack.config.js file and change (the ellipsis ... stands for code which shouldn't be modified):

let webpackConfig = {
  stats: {
    errors: false,
    errorDetails: false,


let webpackConfig = {
  stats: {
    errors: true,
    errorDetails: true,

As a result you will get a full error message similar to this:

sage assets building error message


In my case, this error was caused by something which is stored inside .cache-loader directory which is placed directly inside your Sage theme directory. The solution was easy, just delete the .cache-loader dir.