使用react和next.js时找不到fsmodule的错误如何解决
IT技术
node.js
reactjs
next.js
2021-05-13 18:21:14
1个回答
创建 next.config.js 并放置以下代码。这对我来说可以。
下一个.config.js
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
// Example using webpack option
//config.plugins.push(new webpack.IgnorePlugin(/\/__tests__\//))
config.node = {fs:"empty"}
return config
},
webpackDevMiddleware: config => {
// Perform customizations to webpack dev middleware config
// Important: return the modified config
return config
},
}