next-session
next-session copied to clipboard
Module not found with Yarn 2
Hi,
I'm trying to migrate my NextJS app with Yarn 2 (version 3.1.1) and PnP, but when app compile I've got an error which says next-session is not defined. Stacktrace suggestion is to import /lib/session, but it doesn't work either.
Is there a reason why is does not work ?
Stacktrace :
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'next-session' imported from /Users/xxxxxx/.next/server/pages/_app.js
Did you mean to import next-session-npm-4.0.4-01166cd426-d602a2d75a.zip/node_modules/next-session/lib/session.cjs?
at new NodeError (node:internal/errors:371:5)
at packageResolve (node:internal/modules/esm/resolve:894:9)
at moduleResolve (node:internal/modules/esm/resolve:940:18)
at defaultResolve (node:internal/modules/esm/resolve:1043:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ESMLoader.import (node:internal/modules/esm/loader:332:22)
at importModuleDynamically (node:internal/modules/cjs/loader:1036:29)
at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
at importModuleDynamically (node:vm:381:46)
This seems related to https://github.com/hoangvvo/next-connect/issues/163. Can you try the solution mentioned in that issue?
I will give a try to yarn canary version.
Yarn 3 has support for ESM modules.