I've been developing an app using Webpack, Vue.js and Rails. No problems for two months, but out of nowhere when I try to start rails console rails c
, yarn
complains that packages out of date:
error An unexpected error occurred: "Unknown language key integrityNodeDoesntMatch".
info If you think this is a bug, please open a bug report with the information provided in "/Users/maksimfedotov/vras/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.
========================================
Your Yarn packages are out of date!
Please run `yarn install` to update.
========================================
Yet when I run yarn install
:
yarn install v1.3.2
[1/4] đ Resolving packages...
success Already up-to-date.
⨠Done in 0.71s.
I've been looking through yarn and webpacker documentation, tried various yarn
cleanup commands, but no luck.
Interestingly enough, I can still run the server, its only console that complains.
To solve the error "yarn: command not found", install the yarn package globally by running npm install -g yarn and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.
yarn install is used to install all dependencies for a project. This is most commonly used when you have just checked out code for a project, or when another developer on the project has added a new dependency that you need to pick up.
This is an old issue, which has been resolved, so I am writing down what I did in the end:
Simply deleting node_modules
usually solves the issue. If you are using spring, it also can mess this up, so consider running DISABLE_SPRING=1 rails s
to see if that helps
Try restarting spring by running spring stop
.
This fixed the issue for me, and meant I didn't need to constantly prefix commands with the spring disable flag.
The above command stops spring: to check that it automatically restarted, run spring status
.
Credit to this comment on GitHub for the solution!
You can add in the config/environments/development.rb
this configuration setting
config.webpacker.check_yarn_integrity = false
It also it forget to check yarn integrity on every rails call, as migrations, launching consoles ..., in development environment
This problem resurfaced in April 2021 due to compatibility issues between node-sass and node version 16. (I had similar problems here and provide a similar answer to that below here).
So my solution is to downgrade node until version 16 is fully compatible.
Install node 14 with nvm install 14
, then set it to the global default with nvm alias default 14
.
Then:
node --version
returns 14.x
(not 16)spring stop
yarn.lock
rm -rf node_modules
node --version
returns 14. If it doesn't run nvm install 14
again.yarn install
(if you don't have yarn for node 14, install it with npm install --global yarn
)Other useful info:
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