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

I get the following error from webpack #2

Closed
EarthlingDavey opened this issue May 5, 2020 · 1 comment
Closed

I get the following error from webpack #2

EarthlingDavey opened this issue May 5, 2020 · 1 comment

Comments

@EarthlingDavey
Copy link

I get this error. I think it's linked to this issue floatdrop/require-from-string#18

Module not found: Can't resolve 'module' in '/var/app/node_modules/require-from-string'
ModuleNotFoundError: Module not found: Error: Can't resolve 'module' in '/var/app/node_modules/require-from-string'
    at /var/app/node_modules/webpack/lib/Compilation.js:925:10
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:401:22
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:130:21
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:224:22
    at /var/app/node_modules/neo-async/async.js:2830:7
    at /var/app/node_modules/neo-async/async.js:6877:13
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:214:25
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:213:14
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/var/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /var/app/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/var/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/var/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /var/app/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
[ error ] ./node_modules/require-from-string/index.js
Module not found: Can't resolve 'module' in '/var/app/node_modules/require-from-string'

I have this in my next.config.js

module.exports = {
  webpack: (config, { isServer }) => {
    // Fixes npm packages that depend on `fs` module
    if (!isServer) {
      config.node = {
        fs: 'empty',
      };
    }

    return config;
  },
};

If I have an empty config I get this error:

[ error ] ./node_modules/@babel/helper-create-regexp-features-plugin/node_modules/@babel/core/lib/transformation/normalize-file.js
Module not found: Can't resolve 'fs' in '/var/app/node_modules/@babel/helper-create-regexp-features-plugin/node_modules/@babel/core/lib/transformation'
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in '/var/app/node_modules/@babel/helper-create-regexp-features-plugin/node_modules/@babel/core/lib/transformation'
    at /var/app/node_modules/webpack/lib/Compilation.js:925:10
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:401:22
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:130:21
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:224:22
    at /var/app/node_modules/neo-async/async.js:2830:7
    at /var/app/node_modules/neo-async/async.js:6877:13
    at /var/app/node_modules/webpack/lib/NormalModuleFactory.js:214:25
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:213:14
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/var/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /var/app/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/var/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /var/app/node_modules/enhanced-resolve/lib/Resolver.js:285:5
    at eval (eval at create (/var/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /var/app/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43

dependencies in package.json

  "dependencies": {
    "@apollo/react-hooks": "^3.1.4",
    "@apollo/react-ssr": "^3.1.4",
    "@mdx-js/runtime": "^1.6.1",
    "@types/react": "^16.8.0",
    "apollo-cache-inmemory": "^1.6.5",
    "apollo-client": "^2.6.8",
    "apollo-link-http": "^1.5.17",
    "apollo-link-ws": "^1.0.20",
    "apollo-utilities": "^1.3.3",
    "graphql": "^14.3.1",
    "graphql-tag": "^2.10.3",
    "isomorphic-unfetch": "^3.0.0",
    "mdx.macro": "^0.2.9",
    "next": "^9.3.4",
    "next-mdx-remote": "^0.3.0",
    "next-seo": "^4.4.0",
    "next-translate": "^0.14.3",
    "next-with-apollo": "^5.0.0",
    "nprogress": "^0.2.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "subscriptions-transport-ws": "^0.9.16"
  }
@EarthlingDavey
Copy link
Author

Issue is resolved by creating .babelrc in project root with `{ "presets": ["next/babel"] }

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

1 participant