Skip to content

Commit 3ed6e66

Browse files
committed
Fix Webpack 5 "configuration[0].node has an unknown property 'fs'."
1 parent 1c1496a commit 3ed6e66

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

next.config.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ module.exports = withBundleAnalyzer(withSourceMaps({
186186
webpack5: true,
187187
},
188188

189+
resolve: {
190+
fallback: {
191+
// Fixes npm packages that depend on `fs` module
192+
fs: false,
193+
},
194+
},
195+
189196
/**
190197
* The webpack function is executed twice, once for the server and once for the client.
191198
* This allows you to distinguish between client and server configuration using the isServer property.
@@ -218,11 +225,6 @@ module.exports = withBundleAnalyzer(withSourceMaps({
218225
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"' : ''}`);
219226
}
220227

221-
// Fixes npm packages that depend on `fs` module
222-
config.node = {
223-
fs: 'empty',
224-
};
225-
226228
// XXX See https://github.com/vercel/next.js/blob/canary/examples/with-sentry-simple/next.config.js
227229
// In `pages/_app.js`, Sentry is imported from @sentry/node. While
228230
// @sentry/browser will run in a Node.js environment, @sentry/node will use

0 commit comments

Comments
 (0)