Exports is not defined in ES module scope
See original GitHub issueEnvironment
- Operating System:
Windows_NT - Windows 10 Pro, Version 21H1 (OS Build 19043.1288), WFEP 120.2212.3920.0
- Node Version:
v16.11.1
- Nuxt Version:
3.0.0-27248715.54549cf
- Package Manager:
Yarn
- Bundler:
Vite
- User Config:
srcDir
,ssr
- Runtime Modules:
-
- Build Modules:
-
Describe the bug
When using a third-party src folder (which is not the current folder) and when server rendering is enabled, an error 500 appears - exports is not defined in ES module scope
Reproduction
- run
npx nuxi init
andyarn install
- create
src
dir and secondapp.vue
for example (or pages/index.vue) - run yarn dev
I couldn’t change the node js version on stackblitz and codesandbox, so I’m attaching my git repo for example https://github.com/eakhadov/nuxt3-bug
Additional context
srcDir: './src', ssr: true
= error
srcDir: './src', ssr: false
= ok
srcDir: '.', ssr: true
= ok
srcDir: '.', ssr: false
= ok
Logs
Nuxt CLI v3.0.0-27248715.54549cf 00:19:35
00:19:35
> Local: http://localhost:3000/
> Network: http://192.168.208.1:3000/
> Network: http://172.24.112.1:3000/
> Network: http://192.168.1.3:3000/
> Network: http://172.18.192.1:3000/
√ Generated nuxt.d.ts 00:19:41
i Vite warmed up in 1334ms 00:19:42
√ Vite server built in 2178ms 00:19:43
√ Nitro built in 288 ms 00:19:43
exports is not defined in ES module scope
at $id_29efbadd (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:88:23)
at __instantiateModule__ (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:8279:9)
at __ssrLoadModule__ (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:8227:25)
at ssrImport (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:8251:13)
at $id_0a51e162 (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:15:37)
at __instantiateModule__ (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:8279:9)
at __ssrLoadModule__ (file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:8227:25)
at file:///C:/Users/Emil/Desktop/nuxt-err/.nuxt/dist/server/server.mjs:8292:22
at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Typescript ReferenceError: exports is not defined
I had the error "exports is not defined" coming from an imported NPM module. Changing my typescript config did nothing as I had...
Read more >ReferenceError: exports is not defined in TypeScript | bobbyhadz
To solve the "Uncaught ReferenceError: exports is not defined", add a script tag that defines an exports variable, e.g. <script>var exports = {};</script>...
Read more >ReferenceError: exports is not defined in ES module scope
Node version: 18. I'm trying to run my project with: node dist/index.js. My tsconfig.json "lib": ["ES5"]. "module": "CommonJS".
Read more >How to fix ReferenceError: exports is not defined TypeScript
If you are getting the error for code that runs in the browser, try defining a global exports variable above the script tags...
Read more >ReferenceError: exports is not defined in ES module scope in ...
ReferenceError : exports is not defined in ES module scope This file is being treated as an ES module because it has a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pi0 @danielroe It seems this issue was closed but this issue still persists on latest commit as of writing this i.e.
^3.0.0-27264278.aba2d22
And like mentioned above setting
ssr
to false solves it, but if ssr is true this error shows upIts happing to me in Mac BigSur