prerender issue: ERROR [nuxt] [request error] exports is not defined in ES module scope
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-rc.4 19:44:27 RootDir: /home/user/workspace/nuxt3-multi-page 19:44:28 Nuxt project info: 19:44:28
- Operating System:
Linux
- Node Version:
v16.15.1
- Nuxt Version:
3.0.0-rc.4
- Package Manager:
yarn@3.2.0
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
👉 Report an issue: https://github.com/nuxt/framework/issues/new 19:44:28
👉 Suggest an improvement: https://github.com/nuxt/framework/discussions/new
👉 Read documentation: https://v3.nuxtjs.org
Reproduction
import {defineNuxtConfig} from 'nuxt'
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
preset: "netlify",
ssr: false,
nitro: {
prerender: {
routes: [
'/blog'
]
}
},
modules: [
'@nuxtjs/tailwindcss'
]
})
Hint: tried it with ssr: true and false
sample component:
<template>
<fetch-method-layout name="useLazyFetch()">
<ul>
<li v-for="post in posts">{{ post.name }}</li>
</ul>
</fetch-method-layout>
</template>
<script setup>
import FetchMethodLayout from "../layouts/FetchMethodLayout";
const {data: posts, pending, error, refresh} = useLazyFetch('/api/posts')
</script>
<style scoped>
</style>
posts.get.ts
// @ts-ignore
export default defineEventHandler((event) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
posts: [
{
"name": "First Post"
},
{
"name": "Second Post"
},
{
"name": "Third Post"
}
]
})
}, 0)
})
})
Describe the bug
Can’t run nuxi build, generate or serve anymore without errors.
Cannot make any sense of the exceptions.
The API is working when I call it directly, the pages are not
Additional context
No response
Logs
> nuxi build
produces
Nuxt CLI v3.0.0-rc.4 19:47:02
ℹ Using default Tailwind CSS file from runtime/tailwind.css nuxt:tailwindcss 19:47:06
ℹ Merging Tailwind config from ~/tailwind.config.js nuxt:tailwindcss 19:47:06
ℹ Vite client warmed up in 3437ms 19:47:11
ℹ Client built in 5178ms 19:47:13
ℹ Building server... 19:47:13
✔ Server built in 2063ms 19:47:15
✔ Generated public .output/public nitro 19:47:15
ℹ Initializing prerenderer nitro 19:47:15
ℹ Prerendering 1 routes nitro 19:47:20
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
ERROR [nuxt] [request error] exports is not defined in ES module scope 19:47:20
at ./.nuxt/prerender/chunks/app/server.mjs:4109:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async ./.nuxt/prerender/chunks/renderer.mjs:11160:24
at async ./.nuxt/prerender/chunks/renderer.mjs:11215:64
at async /home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:420:19
at async nodeHandler (/home/user/workspace/nuxt3-multi-page/node_modules/h3/dist/index.mjs:370:7)
at async ufetch (/home/user/workspace/nuxt3-multi-page/node_modules/unenv/runtime/fetch/index.mjs:9:17)
at async generateRoute (/home/user/workspace/nuxt3-multi-page/node_modules/nitropack/dist/chunks/prerender.mjs:2301:17)
while
nuxi serve
produces
[nuxt] [request error] Cannot set properties of undefined (setting '__esModule')
at $id_5ed6902a (./.nuxt/dist/server/server.mjs:3154:20)
at __instantiateModule__ (./.nuxt/dist/server/server.mjs:5326:9)
at __ssrLoadModule__ (./.nuxt/dist/server/server.mjs:5264:25)
at ssrImport (./.nuxt/dist/server/server.mjs:5289:13)
at $id_16657e2a (./.nuxt/dist/server/server.mjs:3046:38)
at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:5326:3)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
@danielroe I haven’t faced this issue anymore since then and couldn’t reproduce it anymore. I had this issue as well https://github.com/dependabot/dependabot-core/issues/1297#issuecomment-1159518380 and maybe they were related somehow.
In case I’ll see it again, I’ll come back to this issue
Would you provide a reproduction if you are still encountering this? 🙏