[Ruby on Rails] yarn install --check-files

Introduction

An error that occurred when installing node_module in Rails environment.

========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================


To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).

 
yarn check v1.22.5
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

Solutions

This error is displayed if the version and hash value of the package content in package.json ** does not match the one listed in yarn.lock **. In other words, you just have to match the versions of what is described in package.json and yarn.lock.

1. Run yarn upgrade

# package.Update dependencies to the latest version based on the version range specified in json.
$ yarn upgrade

2. Compare package.json and yarn.lock to see if the versions match

Comparing package.json and yarn.lock,

--In package.json, specify to download 2.X.X (at that time, 2.7.3 was the latest version) --In yarn.lock, package.json specifies ^ 2.7.3, so 2.9.4 is downloaded.

package.json


  "dependencies": {
    "chart.js": "^2.7.3"
  }

yarn.lock


chart.js@^2.7.3:
  version "2.9.4"
  resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.9.4.tgz#0827f9563faffb2dc5c06562f8eb10337d5b9684"
  integrity sha512-B07aAzxcrikjAPyV+01j7BmOpxtQETxTSlQ26BEYJ+3iUkbNKaOJ/nDbT6JjyqYxseM0ON12COHYdU2cTIjC7A==
  dependencies:
    chartjs-color "^2.1.0"
    moment "^2.10.2"

Therefore, specify the version of package.json in the same way as that of yarn.lock.

$ yarn upgrade chart.js@^2.9.4
  "dependencies": {
-    "chart.js": "^2.7.3"
+    "chart.js": "^2.9.4"
  }

3. Try launching Rails

$ rails s
=> Booting Puma
=> Rails 6.X.X application starting in development
=> Run `rails server --help` for more startup options
[1] Puma starting in cluster mode...
[1] * Version 4.3.7 (ruby 2.X.X-p137), codename: Mysterious Traveller
[1] * Min threads: 5, max threads: 5
[1] * Environment: development
[1] * Process workers: 1
[1] * Preloading application
[1] * Listening on tcp://0.0.0.0:3000
[1] Use Ctrl-C to stop
[1] - Worker 0 (pid: 81) booted, phase: 0

4. For Docker environment

I don't know why it was solved, but if you are using Docker The above method did not solve the problem, but in some cases it was solved by deleting the Docker process and rebuilding it.

$ docker rm (docker ps -q -a) #Delete all containers
$ docker-compose up

reference

Yarn: Official Site

Recommended Posts

[Ruby on Rails] yarn install --check-files
Install Ruby on Ubuntu 20.04
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
Install Ruby / Rails on Mac M1 Big Sur 2021-01
[Ruby on Rails] How to install Bootstrap in Rails
Portfolio creation Ruby on Rails
Install Sidekiq pro on Rails
Ruby on rails learning record -2020.10.04
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
Ruby on Rails basic learning ①
[Ruby on Rails] about has_secure_password
Ruby on rails learning record-2020.10.07 ②
Install Rails on macOS Catalina
Commentary on partial! --Ruby on Rails
Install Ruby 2.7 on RHEL 8 (AppStream)
Ruby on rails learning record-2020.10.07 ①
Cancel Ruby on Rails migration
Install Ruby 2.7 on CentOS 7 (SCL)
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
Install Ruby on Sakura's VPS
[Ruby] I can't install puma on Mac [Rails, etc.]
Install Ruby on MSYS2 with pacman
Ruby on Rails Overview (Beginner Summary)
[Ruby on Rails] Read try (: [],: key)
Ruby on Rails variable, constant summary
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)
[Ruby on Rails] Introduced paging function
Basic knowledge of Ruby on Rails
Progate Ruby on Rails5 Looking Back
Install Ruby 2.5 on CentOS 7 using SCL
How to use Ruby on Rails
[Ruby on Rails] Add / Remove Columns
Ruby on Rails Japanese-English support i18n
(Ruby on Rails6) "Erase" posted content
[Ruby on Rails] CSV output function
Ruby on Rails 6.0 environment construction memo
[Ruby on Rails] What is Bcrypt?
[Ruby on Rails] Confirmation page creation
Ruby On Rails devise routing conflict
[Ruby on Rails] Comment function implementation
[Ruby on Rails] DM, chat function
[Ruby on Rails] Convenient helper method
Install ruby on Ubuntu 20.04 with rbenv
[Ruby on Rails] Stop "looping until ..."
[Ruby on Rails] Introduction of initial data
[Ruby on Rails] Search function (not selected)
[Rails] Addition of Ruby On Rails comment function
[Ruby on Rails] Creating an inquiry form
Please run `yarn install --check-files` to update.
Ruby on Rails6 Practical Guide cp13 ~ cp15 [Memo]
Install Webpacker and Yarn to run Rails
[Ruby on Rails] View test with RSpec
[Ruby on Rails] How to use CarrierWave
[Ruby on Rails] Code check using Rubocop-airbnb