-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't resolve 'fs' #9866
Comments
I think adding
to your next.config.js can resolve this issue |
In general it means you're importing a server-only dependency in code that will be shipped to client-side users. @BjoernRave it's not recommended to add that as server-only libs are generally massive and will bloat bundle size while working incompletely client-side. Please follow the issue template. https://github.com/zeit/next.js/issues/new/choose https://github.com/zeit/next.js/issues/new?template=8.Question_about_next.md
|
Webpack trick did not solve my problem problem, here is what I did: const context = {
// eslint-disable-next-line @typescript-eslint/no-var-requires
db: typeof window === 'undefined' ? require('diskdb').connect('folder', ['articles']) : null,
}; |
In my case in _app.tsx i was importing |
I have/had the same issue. So I moved a few of server-only requires (redis & other db clients) to inside the getStaticProps/ServersideProps. |
this link solved my issue -->next.config.js module.exports = {
} |
For newer versions of next that use webpack5, use the following in your webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.resolve.fallback = {
fs: false,
};
}
return config;
}, |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Error compiling page in console:
[ ready ] compiled successfully
ready at https://localhost:3000
[ event ] build page: /
[ wait ] compiling ...
[ error ] ./node_modules/destroy/index.js
Module not found: Can't resolve 'fs' in ''C:\Users\admin\projects\gast\node_modules\destroy'
Could not find files for /index in .next/build-manifest.json
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'C:\Users\admin\projects\gast\node_modules\destroy'
I have not used any new packages. It just came out of nowhere
I tried to install all the packages again in a separate folder and transfer the necessary components there. Nothing has changed, the same error
https://github.com/treuh/solgastrobar
The text was updated successfully, but these errors were encountered: