next-shared-cache
next-shared-cache copied to clipboard
next/constants module not found when setting instrumentation
Brief Description of the Bug
We are trying to test the new pre-rendered page population feature, but we're stuck on creating the instrumentation file and enabling instrumentationHook in next.config.js. The error we got is the following:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/project/path/node_modules/next/constants' imported from /project/path/node_modules/@neshca/cache-handler/dist/instrumentation/instrumentation.js Did you mean to import next/constants.js?.
Does this have anything to do with Next's version? We're stuck on version 13 for a while now.
Severity Major
Frequency of Occurrence Always
Steps to Reproduce
- Setting up the example
instrumentationfile. - Enable
instrumentationHookinnext.config.js. - Run
npm run devornpm run buildand thennpm start.
Expected vs. Actual Behavior
We expect that the pre-rendered pages population feature can work smoothly for all the next versions that supports it.
Environment:
- OS: MacOS
- Node.js version: 18.20.3
@neshca/cache-handlerversion: 1.7.3nextversion: 13.5.7
@ffigueroal hello! I am sorry it took so long to answer.
If you are developing your project in a monorepo please ensure that the problem isn't caused by misconfigured tracing. Refer to this Next.js documentation on outputFileTracingRoot at https://nextjs.org/docs/13/app/api-reference/next-config-js/output#caveats.
Howdy! We've experienced similar thing (not a monorepo setup) where also setting experimental esmExternals: falsein next.config.js removes the errors involving ERR_MODULE_NOT_FOUND of next/constants.
Also noticed by setting the following in the config, it seems to work correct.
transpilePackages: ['@neshca/cache-handler']
This leads me to think that there's something going on with how the package is bundled or similar?