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

Module not found error after integrating next-pwa #471

Open
HasanBihan opened this issue Apr 4, 2023 · 1 comment
Open

Module not found error after integrating next-pwa #471

HasanBihan opened this issue Apr 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@HasanBihan
Copy link

HasanBihan commented Apr 4, 2023

Summary

The next.config.js code below was working fine before adding next-pwa. But after the next-pwa integration, i started getting "Module not found" errors.

#ERROR

error - ./node_modules/jest-worker/build/workers/ChildProcessWorker.js:9:0
Module not found: Can't resolve 'child_process'

Import trace for requested module:
./node_modules/jest-worker/build/WorkerPool.js
./node_modules/jest-worker/build/index.js
./node_modules/terser-webpack-plugin/dist/index.js
./node_modules/next-pwa/build-custom-worker.js
./node_modules/next-pwa/index.js
./next.config.js
./store/WorkoutStore.js
./context/MyStudio/MyStudioContext.js
./context/Provider.js
./pages/_app.js

https://nextjs.org/docs/messages/module-not-found

#NEXT.CONFIG.JS

const withPWA = require("next-pwa")({
  dest: "public",
});

module.exports = withPWA({
  // next.js config
  reactStrictMode: true,
  trailingSlash: true,

  pageExtensions: ["mdx", "md", "jsx", "js", "tsx", "ts"],

  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },

  webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    config.module.rules.push({
      test: /\.(png|svg|jpg|jpeg|gif)$/i,
      type: "asset/resource",
    });

    config.module.rules.push({
      test: /\.md$/,
      use: "raw-loader",
    });

    config.module.rules.push({
      test: /\.(woff|woff2|eot|ttf|otf)$/i,
      type: "asset/resource",
    });

    config.module.rules.push({
          test: /\.tsx?$/,
          loader: "ts-loader",
          options: {
            compilerOptions: {
              noEmit: false,
            },
          },
        });

    config.module.rules.push({
      test: /\.js$/,
      loader: "source-map-loader",
      options: {
        filterSourceMappingUrl: (url, resourcePath) => {
          if (/.*\/node_modules\/.*/.test(resourcePath)) {
            return false;
          }
          return true;
        },
      },
    });

    config.resolve.fallback = { fs: false };

    config.resolve.extensions = [
      "",
      ".webpack.js",
      ".web.js",
      ".ts",
      ".tsx",
      ".js",
    ];

    config.resolve.alias.https = "https-browserify";
    config.resolve.alias.http = "http-browserify";

    return config;
  },
});

Versions

"next": "^12.1.0",
"next-pwa": "^5.6.0",

@HasanBihan HasanBihan added the bug Something isn't working label Apr 4, 2023
@ImBIOS
Copy link

ImBIOS commented May 2, 2023

@HasanBihan It seems this repo is dead and the maintainer cannot be contacted for so long now. I've made an immediate response by resurrecting this repo ImBIOS/next-pwa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants