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

Error when trying to use WebpackReactComponentNamePlugin #33

Open
omprakashyadav opened this issue Jun 22, 2023 · 1 comment
Open

Error when trying to use WebpackReactComponentNamePlugin #33

omprakashyadav opened this issue Jun 22, 2023 · 1 comment

Comments

@omprakashyadav
Copy link

Hello Everyone,

I am using NextJS 12 for my application and now wanted to use reflect.run for all my automation testing.
I am getting the following error, when the webpack-react-component-name dependency is added to the package.json.

> Build error occurred
Error: Cannot find module 'webpack/lib/dependencies/NullDependency'
Require stack:
- /Users/om/Evolphin/github/pico-web-application/node_modules/webpack-react-component-name/lib/module-appender.js
- /Users/om/Evolphin/github/pico-web-application/node_modules/webpack-react-component-name/index.js
- /Users/om/Evolphin/github/pico-web-application/next.config.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.mod._resolveFilename (/Users/om/Evolphin/github/pico-web-application/node_modules/next/dist/build/webpack/require-hook.js:183:28)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/om/Evolphin/github/pico-web-application/node_modules/webpack-react-component-name/lib/module-appender.js:1:24)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
  code: 'MODULE_NOT_FOUND',

Here is my entry in package.json:
-> "webpack-react-component-name": "^5.0.5"

Here is how I have included it in my next.config.js

webpack: config => {
    // Alias
    config.resolve.alias["~"] = path.resolve(__dirname + "/src");

    // Svgr
    config.module.rules.push({
      test: /\.svg$/i,
      issuer: /\.[jt]sx?$/,
      use: ["@svgr/webpack"]
    });
    config.plugins.push(new WebpackReactComponentNamePlugin());
    return config;
  }

Can someone help, how to resolve this?

@tmcneal
Copy link
Contributor

tmcneal commented Jul 10, 2023

@omprakashyadav Can you try either installing the 4.x version of this plugin, or verifying that your version of NextJS is using Webpack 5? Our 5.x branch is only compatible with Webpack 5 and this looks like an error related to that.

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

2 participants