Search code examples
next.jsblogscontentlayer

Not installing next-contentlayer in nextjs 14.1.0 version


When I am trying to install next-contentlayer in nextjs 14.1.0. It's showing error. I can't install next-contentlayer. Can anyone suggest me how can I install it?

 `npm install next-contentlayer
  npm ERR! code ERESOLVE
  npm ERR! ERESOLVE unable to resolve dependency tree
  npm ERR! 
  npm ERR! While resolving: [email protected]
  npm ERR! Found: [email protected]
  npm ERR! node_modules/next
  npm ERR!   next@"14.1.0" from the root project
  npm ERR! 
  npm ERR! Could not resolve dependency:
  npm ERR! peer next@"^12 || ^13" from [email protected]
  npm ERR! node_modules/next-contentlayer
  npm ERR!   next-contentlayer@"*" from the root project
  npm ERR! 
  npm ERR! Fix the upstream dependency conflict, or retry
  npm ERR! this command with --force or --legacy-peer-deps
  npm ERR! to accept an incorrect (and potentially broken) 
  dependency resolution.

Solution

  • Basically there is a dependency conflict for next-contentlayer as it need needs next 12 or 13 and the maintainers have not updated for next 14 yet

    You can try 2 things

    1. Downgrade the nextjs to any of the 13 versions ( recommended )
    npm install [email protected]
    npm install next-contentlayer
    
    1. Run with --legacy-peer-deps or --force flag.
    npm install next-contentlayer --force