blitz-js / next-superjson-plugin

SuperJSON Plugin for Next.js Pages and Components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Module not found: ESM packages (superjson) need to be imported.` in Next.js 14.0.4

jack-szeto opened this issue · comments

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I'm encountering a 'Module not found' error related to ESM package handling in Next.js 14.04. The issue arises when trying to use the 'superjson' package in my project.

./node_modules/.pnpm/next-superjson-plugin@0.5.10_next@14.0.5-canary.59_superjson@2.2.1/node_modules/next-superjson-plugin/dist/tools.js:65:18
Module not found: ESM packages (superjson) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/posts/page.tsx

Expected behavior

no error occurs.

Reproduction link

No response

Version

next-superjson-plugin@0.5.10, superjson@2.2.1, next@14.0.5-canary.59

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

module.exports = nextConfig;

Additional context

No response

see #91
project seems to be abandoned.

To fix your issue, downgrade superjson to 1.13.3

npm i --save-exact superjson@1.13.3