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 'child_process' with Next.js #185

Open
shuent opened this issue Apr 14, 2021 · 2 comments
Open

Module not found: Can't resolve 'child_process' with Next.js #185

shuent opened this issue Apr 14, 2021 · 2 comments

Comments

@shuent
Copy link

shuent commented Apr 14, 2021

When I use this remark-prismfor processing markdown, it causes error.

At First, This seems that markdown file does not include the code surrounded with ``` but it was not.

$ npm run dev

error - ./node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:4:19
Module not found: Can't resolve 'child_process'
null
// MdTransformer.tsx

import remark from 'remark'
import remark2react from 'remark-react'
import prism from 'remark-prism'

export const MdToNode = ({ mdText }) => {
  // console.log(prism)
  const processor = remark()
    .use(prism) // Error: Can't resolve 'child_process'
    .use(remark2react)

  return <div>{processor.processSync(mdText).result}</div>
}

This error occurs when this MdTransformer.tsx is read Because below also causes Error.

export const MdToNode = ({ mdText }) => {
  console.log(prism)
  const processor = remark()
    // .use(prism) // Error: Can't resolve 'child_process'
    .use(remark2react)
...
}

Other remark-plugin works fine but only prism plugin does not.

versions

    "gray-matter": "^4.0.2",
    "next": "latest",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "remark": "^13.0.0",
    "remark-prism": "^1.3.6",
    "remark-react": "^8.0.0",
    "remark-slug": "^6.0.0",
@rayhanadev
Copy link

I was using remark-prism yesterday (4-16-2021) to do syntax highlighting for some code on my portfolio and I ran across the exact same issue :/. Hopefully jsdom get's a fix or the project shifts to a different package.

@matildepark
Copy link

If you’re using next.js, you need to run remark-prism on the server side of the tender (getStaticProps etc), not on the client side.

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