Skip to content

Commit

Permalink
Fix Webpack 5 "configuration[0].node has an unknown property 'fs'."
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed May 6, 2021
1 parent 1c1496a commit 3ed6e66
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ module.exports = withBundleAnalyzer(withSourceMaps({
webpack5: true,
},

resolve: {
fallback: {
// Fixes npm packages that depend on `fs` module
fs: false,
},
},

/**
* The webpack function is executed twice, once for the server and once for the client.
* This allows you to distinguish between client and server configuration using the isServer property.
Expand Down Expand Up @@ -218,11 +225,6 @@ module.exports = withBundleAnalyzer(withSourceMaps({
console.debug(`[webpack] Building release "${APP_VERSION_RELEASE}" using NODE_ENV="${process.env.NODE_ENV}" ${process.env.IS_SERVER_INITIAL_BUILD ? 'with IS_SERVER_INITIAL_BUILD="1"' : ''}`);
}

// Fixes npm packages that depend on `fs` module
config.node = {
fs: 'empty',
};

// XXX See https://github.com/vercel/next.js/blob/canary/examples/with-sentry-simple/next.config.js
// In `pages/_app.js`, Sentry is imported from @sentry/node. While
// @sentry/browser will run in a Node.js environment, @sentry/node will use
Expand Down

0 comments on commit 3ed6e66

Please sign in to comment.