nuxt: v3.3.1 breaks v2.16

Environment

  • Operating System: Darwin
  • Node Version: v16.13.1
  • Nuxt Version: 2.16.2
  • Package Manager: npm@9.6.1
  • Builder: webpack

After the recent updates to @nuxt/kit and @nuxt/schema in nuxt v3.31, any nuxt app running on v2.16.* will have a problem if we run npm install without having package-lock.json.

When running npm run dev or npm run build:

 ✖ Nuxt Fatal Error 
   │   Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in                             │
   │   /Users/said/Desktop/Mostafa/Gfinity/repos/stealthoptional/node_modules/@nuxt/kit/package.json 

This was solved when I replaced @nuxt/kit@3.3.1 in package-lock.json with @nuxt/kit@3.2.3 and @nuxt/schema@3.3.1 with @nuxt/schema@3.2.3

Reproduction

Reproducing the issue is easy: 1- Nuxt v2.16.2 project without package-lock.json file. 2- npm install 3- npm run dev or build

Describe the bug

After the recent updates to @nuxt/kit and @nuxt/schema in nuxt v3.31, any nuxt app running on v2.16.* will have a problem if we run npm install without having package-lock.json.

When running npm run dev or npm run build:

 ✖ Nuxt Fatal Error 
   │   Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in                             │
   │   /Users/said/Desktop/Mostafa/Gfinity/repos/stealthoptional/node_modules/@nuxt/kit/package.json 

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 22 (14 by maintainers)

Most upvoted comments

I had the same errors during Vercel deploy as @Rafa410 and @erdemyunsel; using Next 2.15.8.

It does look related to the lockfile. I don’t have evidence that Vercel ignored it. But I noticed @nuxt/kit and @nuxt/schema where both not listed anywhere in my package-lock.json file.

Adding those dependencies directly to the project gets the app building on Vercel:

npm i @nuxt/kit@3.2.3 --save
npm i @nuxt/schema@3.2.3 --save

I’m still not sure about the root cause, but wanted to offer those steps as a clue to those who find this issue.

Thank you for the fix @danielroe

@SunnyAureliusRichard This issue is about a Nuxt 2 project.

In your case, you can either upgrade your Nuxt version or install the version of kit that matches your Nuxt version:

pnpm i @nuxt/kit@3.1.1

Is anyone still experiencing this? If so, I would appreciate a reproduction.

I had the same issue: a pure Nuxt 2 project deployed on Vercel. We hadn’t done any new pushes in a few weeks, today I made a small change to a text, pushed and got the same error:

[fatal] No "exports" main defined in /vercel/path0/node_modules/@nuxt/kit/package.json

Redeploys of previous builds that were working gave the same error.

I found this issue just now and can confirm that nuxt-modules/web-vitals#64 fixed the error. I redeployed the same build that was giving error just before and now it is generated successfully. Thanks for the very quick hotfix.

That’s an interesting idea. I wonder if this is to do with @nuxtjs/web-vitals, which Vercel may be installing for you.

Okay - would you provide a reproduction? 🙏

Would you provide a reproduction? 🙏

I cannot reproduce with a Nuxt 2 project using a module which depends on @nuxt/kit@3.3.1.