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

Cannot find module 'webpack/package.json' problems returned #417

Closed
yura999999999 opened this issue Dec 7, 2020 · 13 comments
Closed

Cannot find module 'webpack/package.json' problems returned #417

yura999999999 opened this issue Dec 7, 2020 · 13 comments

Comments

@yura999999999
Copy link

yura999999999 commented Dec 7, 2020

Hi there,

After upgrade version to 5.0.0 (commit b34b2b2)

Problems with getWebpackVersion returned
#338
#309

Previously was fixed by 7131578

@d3x42 Any solutions? is it a bug?

@d3x42
Copy link
Contributor

d3x42 commented Dec 7, 2020

@yura999999999 It's a bug caused by merged PR with webpack 5 support

@719media
Copy link
Contributor

Is there a known way forward to fix this, or is further investigation required? This requires pinning to 5.0 otherwise it breaks linters. Thank you for any communication.

@Friksel
Copy link

Friksel commented Dec 17, 2020

Having the same issue here. It's even blocking the full eslint checkup by the VS Code eslint extension on the project so it's even causing Eslint to not resolve paths.

Is there a known way forward to fix this, or is further investigation required? This requires pinning to 5.0 otherwise it breaks linters. Thank you for any communication.

A quick workaround in your project is to go to the file node_modules/svg-sprite-loader/lib/utils/get-webpack-version.js and change the const webpackVersion to a hardcoded string of your webpackversion, like so:

const webpackVersion = "4.44.2";

Could this please get some love and be fixed? As this issue is even stopping the full eslint vs code extension / process here. Thanks in advance!

@ryanjmack
Copy link

We have this same issue, but it seems to happen when we go from v5.0.0 -> v5.1.1 or v5.2.1. We are still on webpack v4.44.2

We've had to downgrade this dep back to v5.0.0

@d3x42
Copy link
Contributor

d3x42 commented Dec 19, 2020

Hey folks, could you please provide a repo with a working example of this issue?

@Friksel
Copy link

Friksel commented Dec 20, 2020

Hey folks, could you please provide a repo with a working example of this issue?

I don't believe that's really necesary as it was fixed before by not sniffing the webpack version, but using feature detection. The current version obviously does sniff the webpak version instead again. So guess the solution is in the mentioned commit or the one before that. Please take a look at the references in the 'opening post'.

@d3x42
Copy link
Contributor

d3x42 commented Dec 21, 2020

@Friksel current version use webpack ver detection for correct work with webpack 5. I need an example of the issue to be sure that after the fix it will work correctly.

@719media
Copy link
Contributor

The problem is the inclusion of the getWebpackVersion from utils. That function is bad as it overwrites require.main property. This causes problems in different engines (like vs code). Feature detection should be used instead of this method. At a minimum, require.main shouldn't be getting toyed with.

I wrote about it earlier in this issue: #381

@bzin
Copy link

bzin commented Feb 3, 2021

I start having this problem updating to the latest version 10.0.6 of Next.js.
Without the loader everything works fine so hopefully a fix and solution can be added soon.

vercel/next.js#21789
vercel/next.js#21679 (comment)

@Friksel
Copy link

Friksel commented Feb 21, 2021

We've had to downgrade this dep back to v5.0.0

I've also downgraded all projects to 5.0.0 now, which is the last version that doesn't have this issue (The issue started when making the plugin 'ready for Webpack 5' in 5.1.1) Having to change that function everytime we update node_modules is a pain.

d3x42 pushed a commit that referenced this issue Mar 6, 2021
Webpack versions util cause some troubles, so this fix should cover them

BREAKING CHANGE:
delete get-webpack-version.js

ISSUES CLOSED: #437, #417
@d3x42
Copy link
Contributor

d3x42 commented Mar 6, 2021

I'm working on a fix, please try svg-sprite-loader@5.2.1-remove-get-webpack-version

Also, it would be great if someone checks PR: #440

@Friksel
Copy link

Friksel commented Mar 8, 2021

I'm working on a fix, please try svg-sprite-loader@5.2.1-remove-get-webpack-version

Just did a quick check with 5.2.1-remove-get-webpack-version and the issue seems gone. Didn't do much testing and didn't check all svg-sprite-loader features though, but the problems getWebpackVersion was causing here aren't there anymore and Webpack doesn't complain using the loader and plugin for creating sprites on a projecct here.

Thanks!

@d3x42 d3x42 closed this as completed Mar 13, 2021
@d3x42
Copy link
Contributor

d3x42 commented Mar 13, 2021

fix released in svg-sprite-loader@6.0.0

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

6 participants