我有一个Next.js应用程序使用了接近-api-js,而且我得到了这个错误。
这让人困惑,因为我在任何地方都不使用unencrypted_file_system_keystore。
error - ./node_modules/near-api-js/lib/key_stores/unencrypted_file_system_keystore.js:7:0
Module not found: Can't resolve 'fs'
Import trace for requested module:
./node_modules/near-api-js/lib/key_stores/index.js这个问题是关于使用near-api-js的。当我了解到这个特定问题的更好的解决方案时,我会更新答案,因为这个库中有已知的bug,而下面的答案就像是一个不可靠的解决方案。
发布于 2022-02-03 19:51:48
对我来说,将/next.config.js的内容更改为以下内容似乎解决了这个问题:
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
future: {
webpack5: true, // By default, if you customize webpack config, they switch back to version 4. (backward compatibility?)
},
webpack(config) {
// eslint-disable-next-line no-param-reassign
config.resolve.fallback = {
...config.resolve.fallback,
fs: false, // https://stackoverflow.com/a/67478653/470749
};
return config;
},
};多亏了https://stackoverflow.com/a/67478653/470749!
但我敢打赌,在近api-js中肯定有一个bug。我不认为我应该采取这一步骤。
https://stackoverflow.com/questions/70977437
复制相似问题