N
Nuxt6d ago
Angius

RollupError: [plugin impound] This module cannot be imported in server runtime.

$ nuxt dev
Nuxt 3.14.159 with Nitro 2.10.4 21:35:12
21:35:13
➜ Local: http://localhost:3000/
➜ Network: use --host to expose

➜ DevTools: press Shift + Alt + D in the browser (v1.6.0) 21:35:21

✔ Vite client built in 613ms 21:35:25
✔ Vite server built in 2715ms 21:35:27

[nitro 21:35:28] ERROR RollupError: [plugin impound] This module cannot be imported in server runtime. [importing node_modules/nitropack/node_modules/unenv/runtime/fetch/index.mjs from node_modules/nitropack/dist/runtime/internal/app.mjs]


undefined

✔ Nuxt Nitro server built in 579 ms
$ nuxt dev
Nuxt 3.14.159 with Nitro 2.10.4 21:35:12
21:35:13
➜ Local: http://localhost:3000/
➜ Network: use --host to expose

➜ DevTools: press Shift + Alt + D in the browser (v1.6.0) 21:35:21

✔ Vite client built in 613ms 21:35:25
✔ Vite server built in 2715ms 21:35:27

[nitro 21:35:28] ERROR RollupError: [plugin impound] This module cannot be imported in server runtime. [importing node_modules/nitropack/node_modules/unenv/runtime/fetch/index.mjs from node_modules/nitropack/dist/runtime/internal/app.mjs]


undefined

✔ Nuxt Nitro server built in 579 ms
My dependencies:
"dependencies": {
"@heroicons/vue": "^2.1.5",
"@nuxt/fonts": "^0.10.2",
"@nuxt/image": "^1.8.0",
"@nuxt/kit": "^3.14.159",
"@pinia/nuxt": "^0.7.0",
"es-toolkit": "^1.17.0",
"marked": "^15.0.0",
"nuxt": "^3.14.159",
"nuxt-svgo": "^4.0.5",
"sass": "^1.78.0",
"vue": "^3.5.4",
"vue-router": "^4.4.4",
"zod": "^3.23.8"
},
"dependencies": {
"@heroicons/vue": "^2.1.5",
"@nuxt/fonts": "^0.10.2",
"@nuxt/image": "^1.8.0",
"@nuxt/kit": "^3.14.159",
"@pinia/nuxt": "^0.7.0",
"es-toolkit": "^1.17.0",
"marked": "^15.0.0",
"nuxt": "^3.14.159",
"nuxt-svgo": "^4.0.5",
"sass": "^1.78.0",
"vue": "^3.5.4",
"vue-router": "^4.4.4",
"zod": "^3.23.8"
},
4 Replies
kapa.ai
kapa.ai6d ago
Hi @Angius. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're encountering is related to a server runtime import issue in Nuxt 3. This type of error typically occurs when there's an attempt to import modules that are not compatible with the server runtime environment. Let's break down the problem and potential solutions: 1. The specific error message indicates that there's an issue importing a module from nitropack in the server runtime:
[plugin impound] This module cannot be imported in server runtime. [importing node_modules/nitropack/node_modules/unenv/runtime/fetch/index.mjs from node_modules/nitropack/dist/runtime/internal/app.mjs]
[plugin impound] This module cannot be imported in server runtime. [importing node_modules/nitropack/node_modules/unenv/runtime/fetch/index.mjs from node_modules/nitropack/dist/runtime/internal/app.mjs]
2. This error is often related to ESM (ECMAScript Modules) compatibility issues. Nuxt 3 uses ESM by default, and some modules might not be fully compatible with this setup. To address this issue, you can try the following steps: 1. Update your dependencies: Make sure all your dependencies are up to date, especially Nuxt and its related packages. You're using Nuxt 3.14.159, which is a recent version, but double-check if there are any updates available for other packages. 2. Check for ESM compatibility: Ensure that all the packages you're using are ESM compatible. Some packages might still be using CommonJS, which can cause issues in the Nuxt 3 ESM environment. 3. Transpile problematic dependencies: If you identify a specific package causing the issue, you can try transpiling it. Add the package to the build.transpile array in your nuxt.config.ts file:
export default defineNuxtConfig({
build: {
transpile: ['problematic-package-name']
}
})

export default defineNuxtConfig({
build: {
transpile: ['problematic-package-name']
}
})

This approach is mentioned in the Nuxt documentation on troubleshooting ESM issues (https://nuxt.com/docs/guide/concepts/esm#troubleshooting-esm-issues). 4. Alias libraries: In some cases, you might need to manually alias a library to its CommonJS version. For example:
export default defineNuxtConfig({
alias: {
'problematic-library': 'problematic-library/dist/problematic-library.cjs.js'
}
})

export default defineNuxtConfig({
alias: {
'problematic-library': 'problematic-library/dist/problematic-library.cjs.js'
}
})

This is also mentioned in the Nuxt ESM troubleshooting documentation (https://nuxt.com/docs/guide/concepts/esm#troubleshooting-esm-issues). 5. Check for circular dependencies: Ensure that there are no circular dependencies in your project, as these can sometimes cause similar issues. 6. Clear cache and reinstall dependencies: Sometimes, clearing the Nuxt cache and reinstalling dependencies can resolve such issues:
npx nuxt cleanup
rm -rf node_modules
npm install

npx nuxt cleanup
rm -rf node_modules
npm install

If these steps don't resolve the issue, you might need to investigate further which specific import is causing the problem. You can try commenting out imports in your server-side code to isolate the problematic module. Remember, when working with Nuxt 3, it's important to be aware of the ESM-only nature of packages (https://nuxt.com/docs/guide/going-further/kit#import-kit-utilities) like @nuxt/kit. Make sure you're using ESM syntax (import instead of require) throughout your project. If the problem persists after trying these solutions, you might want to create a minimal reproduction of the issue and seek help from the Nuxt community or file an issue on the Nuxt GitHub repository. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6d ago
<@85903769203642368> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
hiimmox
hiimmox6d ago
GitHub
3.14.0 Rollup errors, preventing build or run · Issue #29804 · nuxt...
Environment Operating System: Windows_NT Node Version: v20.12.2 Nuxt Version: 3.14.0 CLI Version: 3.15.0 Nitro Version: 2.10.3 Package Manager: [email protected] Builder: - User Config: default Runtime Mo...
Hermes Alves
Hermes Alves5d ago
@hiimmox Did you manage to solve it or make it work? I couldn't, I even opened a new issue: https://github.com/nuxt/nuxt/issues/29920
GitHub
Encountering RollupError in Nuxt 3.14.159 Build with Nitro 2.10.4 a...
Environment Nuxt Version: 3.14.159 Nitro Version: 2.10.4 Runtime: Bun, using Nitro preset set to bun Compatibility Mode: Compatibility version set to 4 with compatibilityDate: '2024-03-26' ...
Want results from more Discord servers?
Add your server