question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Eslint Error: Unable to resolve path to module 'next-contentlayer'

See original GitHub issue

Hi. I can’t import anything from ‘next-contentlayer’:

const { withContentlayer } = require('next-contentlayer');
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
ReferenceError: withContentLayer is not defined

The same for:

import { useMDXComponent } from 'next-contentlayer/hooks';

Eslint shows:

Unable to resolve path to module 'next-contentlayer/hooks'

Package.json:

   "contentlayer": "0.0.32",
   "next-contentlayer": "0.0.32",

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16

github_iconTop GitHub Comments

3reactions
krachtstefancommented, May 11, 2022

Just a tip for everyone who has the same issue. You can create a ignore rule in your .eslintrc.json to fix this issue for the entire project:

{
  "rules": {
    "import/no-unresolved": [
      2,
      {
        "ignore": [
          "contentlayer/generated",
          "next-contentlayer/hooks"
        ]
      }
    ]
  }
}
2reactions
chemicalkosekcommented, Apr 9, 2022

@juanpmd I think your issue is with react 18. Downgrading to 17 will fix it @schickling I’m sorry, I’m drowning in work. Yes, I’m still having this issue. I see you’re running the dev server. Can you try building it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found