Yarn install says up to date, yet can't start rails console
Asked Answered
I

8

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.

Idonna answered 2/4, 2018 at 11:35 Comment(5)
Did you try deleting yarn.lock and running yarn install again? – Milkandwater
Have you tried yarn update ? – Coleslaw
I haven't tried either, but this issue just went away. Not sure what happened... – Idonna
I have the same issue with running rails c and rails g .... Deleting node_modules and yarn.lock doesn't help – Havener
Please remember to try spring stop as a simple fix after every configuration change and before deleting anything. – Milt
I
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

Idonna answered 17/3, 2019 at 17:53 Comment(1)
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? – Foxe
F
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!

Foxe answered 8/8, 2019 at 15:43 Comment(0)
B
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

Bask answered 5/3, 2020 at 15:58 Comment(0)
R
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:

Rooftree answered 24/4, 2021 at 14:19 Comment(2)
The only thing I would add, as a possible extra, is to use a .nvmrc with the version added to it – Cherellecheremis
@Cherellecheremis 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) – Rooftree
P
0

Try just yarn install then rails c again

Phenosafranine answered 11/9, 2019 at 10:24 Comment(0)
V
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
Vesuvius answered 13/5, 2020 at 21:48 Comment(0)
S
0

In my case, this solve the problem.

rm -rf yarn.lock
yarn install
Steelwork answered 8/7, 2020 at 1:30 Comment(0)
C
-1

Try this: NODE_ENV=development yarn install

Carpeting answered 7/4, 2018 at 18:2 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.