Solution to the problem of webpack dev server wrong version under rails 6.0 on Mac OS

Time:2019-12-26

error message

Yesterday, I installed Ruby on rails 6.0. I am very happy to initialize the project and install webpacker according to the instructions. After that, I will execute the familiarrails cThe order, however, gives an error:

#Error message fragment

yarn check v1.7.0
success Folder in sync.
Done in 0.15s.
yarn check v1.7.0
error "webpack-dev-server#yargs#cliui" is wrong version: expected "^4.0.0", got "5.0.0"
error "webpack-dev-server#yargs#yargs-parser" is wrong version: expected "^11.1.1", got "13.1.1"
error Found 2 errors.
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

Solution

At present, I don’t feel much about the materials related to rails 6.0. Fortunately, I found a Japanese post and successfully solved the above problems:

$ brew upgrade yarn
$ yarn upgrade

Finally, the problem is solved and we can move forward happily again!

Be careful:I haven’t developed the rails project for more than a year, and the full stack development is even longer. Rails 6.0 has changed a lot. I haven’t been familiar with many new components myself, so I won’t do the principle analysis of the above solution in this article. Just for the sake of notes, others may encounter the same problem.

Reference material

  • When rails 6 is turned on, it’s called “webbacker” and “yarn” is the solution