22

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.

tk421
  • 5,775
  • 6
  • 23
  • 34
Maxim Fedotov
  • 1,349
  • 1
  • 18
  • 38

8 Answers8

20

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

Maxim Fedotov
  • 1,349
  • 1
  • 18
  • 38
  • Deleting node_modules didn't work for me, but disabling spring did. Is there a way to get spring and webpacker to play nice together? – lucas Aug 08 '19 at 15:29
17

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!

lucas
  • 1,050
  • 12
  • 21
5

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

anquegi
  • 11,125
  • 4
  • 51
  • 67
1

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:

  1. Stop your rails server if it's running
  2. Open a fresh new terminal window (so that node --version returns 14.x (not 16)
  3. Run spring stop
  4. Delete yarn.lock
  5. Remove existing node modules with rm -rf node_modules
  6. Check that node --version returns 14. If it doesn't run nvm install 14 again.
  7. Now reinstall modules with yarn install (if you don't have yarn for node 14, install it with npm install --global yarn)
  8. It should succeed!
  9. Restart your rails server, and it will work!

Other useful info:

stevec
  • 41,291
  • 27
  • 223
  • 311
  • 1
    The only thing I would add, as a possible extra, is to use a `.nvmrc` with the version added to it – BenKoshy Jan 07 '22 at 05:10
  • 1
    @BenKoshy I should probably update this because I think node-sass library has been corrected since, so going to the most recent node version might work now (I’m speculating though) – stevec Jan 07 '22 at 05:13
0

Try just yarn install then rails c again

Feuda
  • 2,335
  • 30
  • 28
0

If you are switching branches which change yarn.lock and just want to run a rails console without having to keep running yarn install everytime you switch, you can add this to your app/config/development.rb

config.webpacker.check_yarn_integrity = ENV['SKIP_YARN'].nil?

Then when rails complains you can simply do this

SKIP_YARN=true rails c
lacostenycoder
  • 10,623
  • 4
  • 31
  • 48
0

In my case, this solve the problem.

rm -rf yarn.lock
yarn install
Son Tr.
  • 776
  • 6
  • 18
-1

Try this: NODE_ENV=development yarn install

Samuel Danielson
  • 5,231
  • 3
  • 35
  • 37