Module not found: Package path ./generated is not exported from package Contentlayer nextJS

628 Views Asked by At

enter image description here I get this error that Module "contentlayer/generated" and its corresponding type declarations are not found.

Solution please .I have installed and updated the dependencies,if someone had the same problem and how the solution

2

There are 2 best solutions below

0
user209245 On

In package.json, I updated scripts to: "dev": "contentlayer dev & next dev",

You can read more in depth about this issue here: https://github.com/contentlayerdev/contentlayer/issues/415

0
linxie On

https://www.contentlayer.dev/docs/getting-started-cddd76b7#3-add-site-code

Notice that you'll get an error when trying to import from contentlayer/generated, it's normal but we're going to fix it later by running the development server.

as the name indicating, it's generated. you need to run npm run dev or npm run build to make contentlayer generating files in the .contentlayer/generated folder.