我试图在我的Next JS项目中使用Instascan,但是我得到了一个错误的Module not found: Can't resolve 'fs' in '/node_modules/instascan/src'。我猜这和SSR有关。我试着用基于this comment的next.config.js文件来设置webpack的配置
module.exports = {
webpack: (config) => {
return Object.assign({}, config, {
node: {
fs: 'empty'
}
})
},
};但这似乎也不起作用,我猜是因为webpack的配置是给客户端的吧?我读到过人们也使用bundle their server using webpack,不是100%确定next是不是这样,也不确定这是否能解决任何问题。有谁能帮我找到解决方案吗?我真的不知道我如何才能继续前进。
发布于 2019-09-05 00:25:24
老实说,我看不出有什么不同,但使用扩散操作符似乎可以解决这个问题?
module.exports = {
webpack: (config) => {
return {
...config,
node: {
fs:
'empty'
}
}
}
};现在我得到一个Instascan-specific的问题,所以这是关闭。
https://stackoverflow.com/questions/57791057
复制相似问题