Skip to content
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

Module not found: Can't resolve 'fs' #8

Open
friskomayufid opened this issue Sep 29, 2021 · 2 comments
Open

Module not found: Can't resolve 'fs' #8

friskomayufid opened this issue Sep 29, 2021 · 2 comments

Comments

@friskomayufid
Copy link

Hi, just wanna ask
in section render content and getStaticProps on file [slug].tsx why in my code it keep saying module 'fs' not found but in blog list its working?

my node version is v14.17.6
and next is 10.0.3

./pages/blog/[slug].tsx:6:0
Module not found: Can't resolve 'fs'
4 | import Head from 'next/head'
5 | import { useRouter } from 'next/router'

6 | import fs from 'fs'
7 | import path from 'path'
8 | import matter from 'gray-matter'
9 | import renderToString from 'next-mdx-remote/render-to-string'

@dhenriquezunosquare
Copy link

dhenriquezunosquare commented May 18, 2022

In Next.config.js Add

 module.exports={
   webpack: (config, { isServer }) => {   
    if (!isServer) {
      config.node = {
        fs: 'empty'
      }
    }
    return config
  },
  /// ... rest conten of file
}

@faroukaf
Copy link

faroukaf commented Oct 6, 2022

check it

  • getStaticProps
  • getStaticPaths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants