Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmet peer dependencies #1078

Closed
DaniG2k opened this issue Dec 10, 2017 · 32 comments
Closed

Unmet peer dependencies #1078

DaniG2k opened this issue Dec 10, 2017 · 32 comments

Comments

@DaniG2k
Copy link

DaniG2k commented Dec 10, 2017

Hello,

Every time I run yarn install on my Rails project I'm seeing warning messages like:

warning " > @rails/[email protected]" has unmet peer dependency "coffeescript@>= 1.12.7 || >= 2.x".
warning "@rails/webpacker > [email protected]" has unmet peer dependency "coffeescript@>= 1.8.x".
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 "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".

My packages.json file looks like this:

{
  "license": "UNLICENSED",
  "dependencies": {
    "@rails/webpacker": "^3.0.1",
    "vue": "^2.4.3",
    "vue-loader": "^13.0.4",
    "vue-resource": "^1.3.4",
    "vue-template-compiler": "^2.4.3",
    "vue2-dropzone": "^3.0.0",
    "vuelidate": "^0.6.1"
  },
  "devDependencies": {
    "webpack-dev-server": "^2.8.1"
  },
  "version": "1.3.2"
}

I am using node 8.9.2:

→ which node
/Users/me/.nvm/versions/node/v8.9.2/bin/node

Am I doing something incorrectly?

Thanks!

@aditya-vector
Copy link

aditya-vector commented Dec 11, 2017

Did you try yarn upgrade and see if it works fine? Also, I am not sure how recommended it is, but try getting rid of yarn.lock file (which helps lock your packages and dependencies) and see if it helps.

@gauravtiwari
Copy link
Member

Please upgrade to latest version of webpacker: yarn upgrade @rails/webpacker.

@serixscorpio
Copy link

@gauravtiwari Sorry to add to this closed ticket. I'm encountering similar unmet peer dependencies even after having upgraded to latest version of webpacker 3.1.1 (using yarn upgrade @rails/webpacker). Then I tried a fresh install and came across the same unmet peer dependencies warnings.

Repro steps:

  1. rails new demo
  2. add webpacker 3.1.1 to Gemfile, and bundle
  3. rake webpacker:install
    Warning messages:
warning "@rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".

resulting package.json:

{
  "dependencies": {
    "@rails/webpacker": "^3.1.1",
    "coffeescript": "1.12.7"
  },
  "devDependencies": {
    "webpack-dev-server": "^2.9.7"
  }
}

I use yarn version 1.3.2.

@gauravtiwari
Copy link
Member

@serixscorpio No problem :)

Those warnings are harmless (apart from generating noise) but if you are concerned you can use versions of webpack-dev-server per warnings since it's a peer dependency.

@jaredbeck
Copy link
Contributor

Please upgrade to latest version of webpacker: yarn upgrade @rails/webpacker.

So, bundle exec rails webpacker:install installs an old version? Should we add yarn upgrade to the instructions in the readme? Or should we fix webpacker:install?

jaredbeck added a commit to jaredbeck/webpacker that referenced this issue May 11, 2018
leppert added a commit to leppert/h2o that referenced this issue Oct 1, 2018
leppert added a commit to leppert/h2o that referenced this issue Oct 5, 2018
leppert added a commit to leppert/h2o that referenced this issue Oct 22, 2018
cgruppioni pushed a commit to harvard-lil/h2o that referenced this issue Oct 22, 2018
@jrochkind
Copy link

Those warnings are harmless (apart from generating noise) but if you are concerned you can use versions of webpack-dev-server per warnings since it's a peer dependency.

I am very new to fancy modern style of JS and webpack in general. I do not understand how to follow those instructions to "use versions of webpack-dev-server per warnings." Can you add an example for those who find themselves here? Thanks!

@gauravtiwari
Copy link
Member

I am not sure if this is an issue with the latest RC (version 4).

@danielnolan
Copy link

This is still an issue with RC 4. Webpacker doesn't seem to add webpack to the package.json, it only adds it to the yarn.lock. I get tons of warning of unmet peer dependencies for webpack. I'm no js expert, but I believe webpack should be added to the dev dependencies of the package.json. A simple yarn add webpack --dev makes these warnings go away.

@jakeNiemiec
Copy link
Member

Adding webpack to devDependencies will prevent you from building/deploying to a production environment (devDependencies are removed when env == production ).  

Have you tried resolving the unmet peer dependencies? Does yarn add webpack successfully add webpack to package.json?

@danielnolan
Copy link

danielnolan commented Jan 17, 2019

@jakeNiemiec yarn add webpack does make the warnings go away, and adds it to package.json

@danielnolan
Copy link

@jakeNiemiec While adding webpack to the package.json via yarn add webpack works and gets rid of the warnings, it no longer works properly inside of Rails. The server fails to start and complains about missing modules. Removing webpack from the package.json and restarting the server makes everything work like normal again.

@jakeNiemiec
Copy link
Member

Did you try: bundle exec rails webpacker:install or yarn upgrade? It sounds like the module was added to your package.json but the install step was not run.

@benoitongit
Copy link

Just did a fresh install and I am still having this issue:
gem 'webpacker', '>= 4.0.x'
yarn add @rails/webpacker@next
bundle
bundle exec rails webpacker:install
yarn upgrade

yarn upgrade didn't fix anything for me.

yarn install v1.12.3
[1/6] 🔍 Validating package.json...
[2/6] 🔍 Resolving packages...
[3/6] 🔍 Auditing packages...
[4/6] 🚚 Fetching packages...
[5/6] 🔗 Linking dependencies...
warning "@rails/webpacker > pnp-webpack-plugin > [email protected]" has unmet peer dependency "typescript@*".
warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".

@DNA
Copy link

DNA commented Mar 27, 2019

Those warnings are about peer dependecies, so it not a problem.

The error webpack-dev-server has unmet peer dependency "webpack@^4.0.0". means "If you are using webpack in your project, make sure its version ^4.0.0 or else webpack-dev-server can break!"

To get rid of the warning, just add the lib/version specified in the warning on your package.json:

"dependencies": {
  ...
  "webpack": "^4.0.0",
  ...
},

@jakeNiemiec
Copy link
Member

@DNA Ensure that you put webpack in dependencies instead of devDependencies see: #1078 (comment)

@DNA
Copy link

DNA commented Mar 27, 2019

@jakeNiemiec You are right, I wrote the wrong section in the example, I've fixed it :)

@josemigallas
Copy link

I'm upgrading to webpacker 4 and due to the unmet peer deps license_finder is failing and thus breaking my CI pipelines.. all is lost! 🙌

/Users/jgallaso/.rvm/gems/ruby-2.3.6/gems/license_finder-5.5.2/lib/license_finder/package_managers/npm.rb:38:in `npm_json': Command 'npm list --json --long --production' failed to execute: npm ERR! peer dep missing: typescript@*, required by [email protected] (RuntimeError)

@jakeNiemiec
Copy link
Member

@josemigallas make sure you have a version that includes this line: https://github.com/arcanis/ts-pnp/blob/master/package.json#L24

The only other thing I can think of is what I warned @.DNA about above: try putting all of your packages in dependencies instead of devDependencies

@josemigallas
Copy link

josemigallas commented Apr 10, 2019

@josemigallas make sure you have a version that includes this line: https://github.com/arcanis/ts-pnp/blob/master/package.json#L24

Do I need to install ts-pnp or typescript for webpacker not to break?

The only other thing I can think of is what I warned @.DNA about above: try putting all of your packages in dependencies instead of devDependencies

Did not help 😕

@jakeNiemiec
Copy link
Member

Do I need to install ts-pnp or typescript for webpacker not to break?

If they are added to your project properly, you should be able to see them in package.json under dependencies . Also, ensure that they get installed within node_modules on the CI server.

@jrochkind
Copy link

Earlier several people said things like "Those warnings are about peer dependecies, so it not a problem." Looking up "peer dependencies" in Webpack, it looks like it's supposed to mean if you have the thing it has to meet a certain version spec, but you are... not required to have the thing?

But do you have to have the thing after all?

I am not a Webpacker/Webpack expert, I'm still quite confused about what's going on. I feel that the promise of Rails/webpacker integration should be to give me something that, immediately after a by-the-book install, does not give me any warnings or errors. I feel that maybe this isssue should be re-opened.

@jakeNiemiec
Copy link
Member

jakeNiemiec commented Apr 10, 2019

@jrochkind I am not a Webpacker/Webpack expert, I'm still quite confused about what's going on.

Say you are making oatmeal for breakfast, you have your oats and a liquid ranging from water to (almond/soy/coconut) milk. The oats don't care what kind of liquid they soak up as long as you provide it. In the same way, ts-pnp does not care what kind typescript configuration your project uses as long as you provide it in your dependencies.

To bring this example home, we ask "Why doesn't ts-pnp just solely use typescript as it's own dependency? This would be like using pre-made oatmeal, the liquid part is "just there" and you don't have the choice to change it. In the same way, the package author not only wants you to provide/configure the dependency for yourself but also wants to be able to build off of your specific configuration.

🤔...perhaps not the best example. This is what yarn says:

Having a peer dependency means that your package needs a dependency that is the same exact dependency as the person installing your package. This is useful for packages like react that need to have a single copy of react-dom that is also used by the person installing it.

The peerDependencies object guarantees that, for each entry, any package that requires you will be requested to provide a copy of the dependency listed here, ideally matching the version you requested. It also guarantees that you’ll be able to access this dependency through require(), and finally it also guarantees that the return of require() will be exactly the same version & instance than the one your parent would obtain if they were to require() it themselves.

As a rails dev, you never need to worry about peerDeps apart from ensuring that they are listed in your project's dependencies.

@jrochkind
Copy link

jrochkind commented Apr 10, 2019

As a rails dev, you never need to worry about peerDeps apart from ensuring that they are listed in your project's dependencies.

In a Rails 5.2 app that was generated with rails new --webpack (or alternately added with bundle exec rails webpacker:install), are the peerDeps listed in the projects dependencies? I think maybe not based on the error messages reported at the top of this ticket? (Which I've encountered too).

Should they be in your projects dependencies already as generated by Rails? Or if not, should there be some clear instructions somewhere telling you to add them? (If I'm understanding right that you need to "ensure that they are listed in your projects dependencies".)

It seems like Rails is setting you up incorrectly here, if you need to ensure the peerDeps are listed in your project's dependencies, but the Rails template doesn't do that for you, and nothing else tells you to. If I'm understanding right what's going on -- because other comments in this ticket said you didn't need to do anything in response to "has unmet peer dependency" warnings. But I think you are disagreeing and saying you do need to do something, you need to ensure the peer dependency is listed in your project's dependencies. (Via... yarn add I guess?) This is confusing and I feel like Rails is dropping the ball somewhere.

The README currently says:

Optional: To fix "unmet peer dependency" warnings,

   yarn upgrade

But yarn upgrade did not fix the "unmet peer dependency warnings", and this ticket was closed anyway. That section of the README actually links here to this very ticket... if I follow it from the README, I am still left unsure what the official webpacker instructions are here.

Not sure how Rails 6 changes things.

@jakeNiemiec
Copy link
Member

should there be some clear instructions somewhere telling you to add them?

Lots of great examples here: https://github.com/rails/webpacker/tree/master/docs

This is confusing and I feel like Rails is dropping the ball somewhere.

This is the key thing: when you make use of package.json & webpack, you have left Rails-land and enter node.js land. The rules are different and I agree that webpackER does not to a good job conveying that.

But yarn upgrade did not fix the "unmet peer dependency warnings"

I don't think that would work for every instance of that error. I would just do yarn add [email protected] as the error indicates.

So: warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
is fixed with:
yarn add webpack@^3.0.0

Not sure how Rails 6 changes things.

Rails 6 uses a different version of webpack (4).

@jrochkind
Copy link

OK, yes. But it seems wrong to me that a fresh untouched rails new --webpack (or just rails new if it's default in Rails 6?) gives you something that, before you've done anything else to it, has "unmet peer dependencies" that you need to take manual actions to resolve.

I'm not sure if you're not understanding me, or you just disagree and think this is appropriate, that it's fine that the fresh out of the box un-touched generated Rails app has unmet peer dependencies that a developer needs to notice and take action to resolve? You can disagree!

(I also think it's a problem that the README links to this issue, which has people saying you can just ignore the "unmet peer dependecies" and don't need to do anything -- and indeed that is what I've been doing in my Rails 5.2 app based on that advice. But if I understand you right you are saying that is bad advice?)

@jakeNiemiec
Copy link
Member

it seems wrong to me that a fresh untouched rails new --webpack gives you something that has "unmet peer dependencies" that you need to take manual actions to resolve.

I agree this would be a good PR candidate. You could add the needed deps somewhere around here:

https://github.com/rails/webpacker/blob/master/lib/install/template.rb#L37-L46

@domchristie
Copy link

I too had this issue, with this error message as other have experienced:

warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".

Both yarn upgrade and yarn add webpack didn't work for me :(. However, the following did:

yarn upgrade webpack@^4.0.0

🎉 Hope that helps!

@paulodeon
Copy link

My personal experience on Rails 5.2.3 I had a lot of these warnings related to webpack

warning " > @ckeditor/[email protected]" has unmet peer dependency "webpack@^4.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@>=2".
warning " > [email protected]" has unmet peer dependency "webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".

I also had the latest version of webpack, 4.34.0

I added this to my package.json and it seemed to get rid of all the warnings:

  "resolutions": {
    "webpack": "4.34.0"
  }

@brentgreeff

This comment has been minimized.

@djangones
Copy link

Both yarn upgrade and yarn add webpack didn't work for me :(. However, the following did:

yarn upgrade webpack@^4.0.0

@domchristie I can confirm that only that adds the necessary dependency

"webpack": "^4.0.0"

into the dependencies section of the package.json file.

Thank you!

lethang7794 added a commit to lethang7794/rails_sample_app that referenced this issue May 20, 2020
- Showed when run "yarn install --check-files" and push to heroku.
- By run "yarn upgrade webpack@^4.0.0" to add "webpack": "^4.0.0" to 
package.json.
- Followed by run "yarn install --check-files" to update the yarn.lock 
file.
(Source: rails/webpacker#1078)
@rlogwood
Copy link

rlogwood commented Jul 19, 2020

Is this change going to be made in the template that creates a new rails app? IMO a new app should not have any errors. I also found the recommended solution on this thread, but wasted a lot of time on it. It's a confusing error for someone coming to rails for the first time and webpack especially.

I think we want rails to be able to create the cononical hello world app without errors. IMHO that's good for the platform, otherwise, I think people who come to rails for the first time to try it out may get discouraged.

I don't know much about the rails implementation of webpacker and how it is different from webpack and if there are any incompatibilities. However, if the recommended solution for those who do know these details is adding this dependency package.json for a new rails app, it seems reasonable to keep this issue open until that has been done. Any agreement? Thank You

@rlogwood
Copy link

The webpacker gem links to this page where I must waste my days to read this whole thread. - needs a one-liner urgently.

I don't understand why this comment was marked as spam, it represents the frustration that a new rails 6 user could experience because of the errors discussed here. Let's fix this for Rails 6 please. This issue was created before Rails 6 was released! I'm happy to volunteer to make the fix. Please reopen rails/rails#39870 or create a new issue as needed. Thank You

jivdhaliwal pushed a commit to ministryofjustice/staff-device-dns-dhcp-admin that referenced this issue Aug 12, 2020
This fixes the following errors during the asset precompilation step

warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".

See rails/webpacker#1078
jivdhaliwal pushed a commit to ministryofjustice/staff-device-dns-dhcp-admin that referenced this issue Aug 13, 2020
This fixes the following errors during the asset precompilation step

warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".

See rails/webpacker#1078
jivdhaliwal pushed a commit to ministryofjustice/staff-device-dns-dhcp-admin that referenced this issue Aug 13, 2020
This fixes the following errors during the asset precompilation step

warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".

See rails/webpacker#1078
slothbear added a commit to slothbear/nova-zocalo that referenced this issue Feb 16, 2021
rails/webpacker#1078

Goal: get rid of warnings about peer dependencies unmet.
Closes #146.
KingTiger001 added a commit to KingTiger001/Rails-web-pack-project that referenced this issue Jan 15, 2023
smartech7 pushed a commit to smartech7/ruby-webpacker that referenced this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests