Webpacker: Warnings: has unmet peer dependency

Created on 3 Nov 2017  ยท  23Comments  ยท  Source: rails/webpacker

I use the latest Rails (5.1.4), Yarn (1.2.1) and Webpacker (3.0.2) version to test Vue. I have created a project with the following commands:

$ gem install bundler rails
$ rails new example_app --webpack=vue

I get this (4 has unmet peer dependency) warnings:

$ cd example_app
$ yarn install --check-files
yarn install v1.2.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "[email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning "[email protected]" has unmet peer dependency "css-loader@*".
warning "[email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "[email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
[4/4] Building fresh packages...
Done in 8.07s.

My package.json looks like this:

{
  "name": "example_app",
  "private": true,
  "dependencies": {
    "@rails/webpacker": "^3.0.2",
    "coffeescript": "^2.0.2",
    "vue": "^2.5.2",
    "vue-loader": "^13.3.0",
    "vue-template-compiler": "^2.5.2",
  },
  "devDependencies": {
    "webpack-dev-server": "^2.9.4"
  }
}

Most helpful comment

I was able to fix it after some guessing... I'm new to yarn but fixed 4 warnings including the one here.

[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning "@rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > [email protected]" has unmet peer dependency "css-loader@*".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-standard@>=3.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
โ””โ”€ [email protected]
โœจ  Done in 5.03s.

I'll list my fixes individually so you can see the pattern:

# 1) @rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
bin/yarn add caniuse-lite@^1.0.30000697
# 2) warning " > [email protected]" has unmet peer dependency "css-loader@*".
bin/yarn upgrade css-loader -p
# 3) warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
# 4) warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
yarn upgrade webpack@^2.2.0 || ^3.0.0

Be sure to use the appropriate dependency flags referenced in the warning, more info here:
https://yarnpkg.com/lang/en/docs/managing-dependencies/

After I ran those lines... I got what I spent hours trying to achieve... 0 warnings ๐Ÿ˜„ :

โ‡’  yarn install --check-files
yarn install v1.3.2
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
โœจ  Done in 7.45s.

All 23 comments

Please feel free to bump up/down your deps. We will try to lock down deps in next release ๐Ÿ‘

I'm trying the same (inside docker) and my install does not have bin/webpack-dev-server. Could it be caused by that? How to set deps correctly?

@gauravtiwari is there a way to start a new project now or should I wait for next release? I'm trying rails webpacker:install and rails webpacker:install:vuebut I' always getting:

Webpack binstubs not found.
Have you run rails webpacker:install ?
Make sure the bin directory or binstubs are not included in .gitignore

@hovancik No, you can start one now. Is this a new project you are getting this error?

Yep.

Could you please run? bundle binstubs webpacker --force before running rails webpacker:install:vue This command takes care of it though: rails webpacker:install

Still nothing. Here is a repo with what I do (https://github.com/hovancik/rails_vue_test). You can check the commits and readme to see what's going on.

Interesting part is on README.md:350

Installing binstubs
         run  bundle binstubs webpacker from "."
Skipped webpack and webpack-dev-server since they already exist.

Thought webpack-dev-serveris not at ./bin

I suspect this PR#883, broke the creation of the binstubs (not confirmed). bundle binstubs wepacker doesn't create them even if you use the --force option.

However you should be able to run the webpack server with bundle exec webpack-dev-server

I'm getting bundler: command not found: bin/webpack-dev-server. I don't think it's possible to run it without binary.

thats strange... hmm... you could try running bundle install --all this will generate all the binstubs for all gems in your gemfile. both this and running with bundle exec works on mac and linux (docker) env

BTW, have you set a different path for binstubs? http://bundler.io/v1.10/bundle_binstubs.html

If yes, use bundle exec webpack-dev-server and bundle exec webpack

@gauravtiwari All that I did is in repo's readme, so nope.
@hass-laughingman bundle install --all yields Unknown switches '--all'

@gauravtiwari I do think there is a issue with the gem not generating binstubs on bundle binstubs webpacker --force I've tested this on a new rails project and on a clean linux environemnt

@hovancik sorry my bad... please try bundle install --binstubs

@hass-laughingman that did work

but not sure if it's ok, eg. rails binary was changed to:

bundle_binstub = File.expand_path("../bundle", __FILE__)
load(bundle_binstub) if File.file?(bundle_binstub)

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
  Pathname.new(__FILE__).realpath)

require "rubygems"
require "bundler/setup"

load Gem.bin_path("railties", "rails")

from

  load File.expand_path('../spring', __FILE__)
rescue LoadError => e
  raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

Yes, that's another way to generate but that would install/update all binstubs (some of it you may not want). Seems to work fine here:

rm -rf ./bin/webpack*
bundle binstubs webpacker

@hovancik Yes, that should be fine - probably you had an older version of Rails bin.

I'm having gem 'rails', '~> 5.1.4' so they should be the latest, unless binstubs goes master or something

@gauravtiwari when I run bundle binstubs webpacker , I'm getting:

Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force

They are not there, thought.

@hovancik Could you please pull in latest master and try again ๐Ÿ‘

gem 'webpacker', github: 'rails/webpacker'

I've not a rather new webpacker install, running master of rails/webpacker, and even after a yarn upgrade I'm still seeing several peer dependency warnings. Is this expected?

โ—Ž $ yarn                                                                                                                                                                                                                           [16:40:08]
yarn install v1.3.2
[1/5] ๐Ÿ”  Validating package.json...
[2/5] ๐Ÿ”  Resolving packages...
[3/5] ๐Ÿšš  Fetching packages...
[4/5] ๐Ÿ”—  Linking dependencies...
warning "@rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
[5/5] ๐Ÿ“ƒ  Building fresh packages...
โœจ  Done in 2.74s.

I was able to fix it after some guessing... I'm new to yarn but fixed 4 warnings including the one here.

[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning "@rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > [email protected]" has unmet peer dependency "css-loader@*".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-standard@>=3.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
โ””โ”€ [email protected]
โœจ  Done in 5.03s.

I'll list my fixes individually so you can see the pattern:

# 1) @rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
bin/yarn add caniuse-lite@^1.0.30000697
# 2) warning " > [email protected]" has unmet peer dependency "css-loader@*".
bin/yarn upgrade css-loader -p
# 3) warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
# 4) warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
yarn upgrade webpack@^2.2.0 || ^3.0.0

Be sure to use the appropriate dependency flags referenced in the warning, more info here:
https://yarnpkg.com/lang/en/docs/managing-dependencies/

After I ran those lines... I got what I spent hours trying to achieve... 0 warnings ๐Ÿ˜„ :

โ‡’  yarn install --check-files
yarn install v1.3.2
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
โœจ  Done in 7.45s.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilrock picture ilrock  ยท  3Comments

ijdickinson picture ijdickinson  ยท  3Comments

suhomlineugene picture suhomlineugene  ยท  3Comments

pioz picture pioz  ยท  3Comments

christianrojas picture christianrojas  ยท  3Comments