Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: exports is not defined in ES module scope #1

Closed
AaronNGray opened this issue Mar 13, 2024 · 2 comments
Closed

ReferenceError: exports is not defined in ES module scope #1

AaronNGray opened this issue Mar 13, 2024 · 2 comments

Comments

@AaronNGray
Copy link
Owner

C:\Users\aaron\Test\node\ts-node-esm-test>npm run start

> ts-node-esm-test@0.0.1 start
> nodemon --exec node --no-warnings=ExperimentalWarning --loader ts-node/esm src/index.ts

[nodemon] 3.1.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `node --no-warnings=ExperimentalWarning --loader ts-node/esm src/index.ts`
file:///C:/Users/aaron/Test/node/ts-node-esm-test/src/index.ts:5
Object.defineProperty(exports, "__esModule", { value: true });
                      ^

ReferenceError: exports is not defined in ES module scope
    at file:///C:/Users/aaron/Test/node/ts-node-esm-test/src/index.ts:5:23
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.11.1
[nodemon] app crashed - waiting for file changes before starting...
@wtfiwtz
Copy link

wtfiwtz commented Mar 17, 2024

Your tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "nodenext",
    "lib": ["dom", "es6", "esnext", "esnext.asynciterable"],
    "skipLibCheck": true,
    "sourceMap": true,
    "outDir": "./dist",
    "moduleResolution": "nodenext",
   ...
 }

You are missing "moduleResolution": "nodenext"

@AaronNGray
Copy link
Owner Author

Okay working fine now !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants