nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
55.15k stars 5.04k forks source link

Encountering RollupError in Nuxt 3.14.159 Build with Nitro 2.10.4 and Bun Preset #29920

Closed hermesalvesbr closed 1 week ago

hermesalvesbr commented 2 weeks ago

Environment

Reproduction

Describe the bug

Steps Taken to Resolve:

  1. Updated Dependencies: All packages, including Nuxt, Nitro, and @nuxt/kit, are updated to the latest versions.
  2. Checked Issue #29804: This issue appears related, as the RollupError mentions a similar plugin impound issue with module imports in server runtime.
  3. Tried Various Nitro Presets: Tested with different Nitro presets (including bun and node-server), but the issue remains unchanged.
  4. Clean Reinstall: Removed node_modules and reinstalled dependencies with both bun install and npm install

Additional context

No response

Logs

bun run build
$ nuxt build
Nuxt 3.14.159 with Nitro 2.10.4                                                        11:00:35 AM
ℹ Using default Tailwind CSS file                                    nuxt:tailwindcss 11:00:36 AM
ℹ Nuxt Icon server bundle mode is set to local                                        11:00:37 AM
[11:00:38 AM] ✔ Nuxt Icon discovered local-installed 3 collections: eos-icons, heroicons, lets-icons
ℹ Running with compatibility version 4                                                11:00:38 AM
ℹ Building client...                                                                  11:00:39 AM
ℹ vite v5.4.11 building for production...         
✔ Generated public .output/public                                               nitro 11:00:47 AM
ℹ Building Nuxt Nitro server (preset: bun, compatibility date: 2024-03-26)      nitro 11:00:47 AM

[nitro 11:00:47 AM]  ERROR  RollupError: [plugin impound] This module cannot be imported in server runtime. [importing ../../node_modules/nitropack/node_modules/crossws/dist/adapters/bun.mjs from ../../node_modules/nitropack/dist/presets/bun/runtime/bun.mjs]

undefined

[11:00:47 AM]  ERROR  [plugin impound] This module cannot be imported in server runtime. [importing ../../node_modules/nitropack/node_modules/crossws/dist/adapters/bun.mjs from ../../node_modules/nitropack/dist/presets/bun/runtime/bun.mjs]

  at getRollupError (/home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
  at error (/home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
  at Object.error (/home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/node-entry.js:20622:20)
  at Object.resolveId (/home/hermes/Projetos-linux/back3nd/node_modules/impound/dist/index.js:29:11)
  at /home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/node-entry.js:20807:40
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async PluginDriver.hookFirstAndGetPlugin (/home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/node-entry.js:20707:28)
  at async resolveId (/home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/node-entry.js:19311:26)
  at async ModuleLoader.resolveId (/home/hermes/Projetos-linux/back3nd/node_modules/rollup/dist/es/shared/node-entry.js:19740:15)
  at async Object.resolveId (/home/hermes/Projetos-linux/back3nd/node_modules/@rollup/plugin-commonjs/dist/es/index.js:600:10)

[11:00:47 AM]  ERROR  [plugin impound] This module cannot be imported in server runtime. [importing ../../node_modules/nitropack/node_modules/crossws/dist/adapters/bun.mjs from ../../node_modules/nitropack/dist/presets/bun/runtime/bun.mjs]

error: script "build" exited with code 1 node --version
v22.2.0
gbyesiltas commented 2 weeks ago

I am encountering the same issue but with node:

[nitro 11:06:56 AM]  ERROR  RollupError: [plugin impound] This module cannot be imported in server runtime. [importing node_modules/nitropack/node_modules/crossws/dist/adapters/node.mjs from node_modules/nitropack/dist/presets/_nitro/runtime/nitro-dev.mjs]

Update: removing node_modules and package-lock.json and then doing a clean install fixed the issue for me

marvhock commented 2 weeks ago

I still get an Error for Node Runtime.

ERROR  RollupError: [plugin impound] This module cannot be imported in server runtime. [importing node_modules/nitropack/node_modules/ofetch/dist/node.mjs from node_modules/nitropack/dist/runtime/internal/app.mjs]

Run with Yarn dev, Nuxt 3.14.159 with Nitro 2.10.4

HenningGeorgi commented 2 weeks ago

I get the same error here :(

llama-for3ver commented 2 weeks ago

Found a "workaround" - I used git to clear all ignored files (git clean -f -X -d) and then used npm to reinstall everything. Afterwards, I could use bun to run it as normal. So does that mean it's something outside node_modules causing it, or how bun install handles things?

CedsTrash commented 2 weeks ago

Same here!

HenningGeorgi commented 2 weeks ago

@llama-for3ver i will also try it with bun, with npm the same error occurs again...

HenningGeorgi commented 2 weeks ago

Solved this issue by updating @azure/cosmos dependency ✅

llama-for3ver commented 2 weeks ago

Solved this issue by updating @azure/cosmos dependency ✅

To what version? It’s been on 4.1.1 for months, and using bun update didn’t do anything.

HenningGeorgi commented 2 weeks ago

@llama-for3ver hm i also updated it to 4.1.1, since that update its working again

llama-for3ver commented 2 weeks ago

@llama-for3ver hm i also updated it to 4.1.1, since that update its working again

What PM did you use?

hermesalvesbr commented 2 weeks ago

@llama-for3ver hm i also updated it to 4.1.1, since that update its working again

How can I do this too?

HenningGeorgi commented 2 weeks ago

Im using npm, just change the version of @azure/cosmos in package.json and then npm install. Let me know, if it solved the problem

llama-for3ver commented 2 weeks ago

Im using npm, just change the version of @azure/cosmos in package.json and then npm install

In that case I'm inclined to believe its how NPM handles things, rather than the dependency itself. Can you confirm?

HenningGeorgi commented 2 weeks ago

Yes, i think so too. It seems like the source of the problem is another at your project :/

pascalvaccaro commented 1 week ago

Just encountered the same issue testing out Nuxt v3.14.159, I simply removed the node_modules folder and the associated lockfile (in my case pnpm-lock.yaml), now it works 👍