Skip to main content

Solution One

  1. Remove "type": "module" from package.json if it's added
  2. In tsconfig.json under the compilerOptions Set module property to CommonJS module: "CommonJS" and moduleResolution: "Node"

Solution Two

if the first one didn't work, or you have for some reason to keep module: "ESNext"

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 
{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

Solution One

  1. Remove "type": "module" from package.json if it's added
  2. In tsconfig.json under the compilerOptions Set module property to CommonJS module: "CommonJS" and moduleResolution: "Node"

Solution Two

if the first one didn't work, or you have for some reason to keep module: "ESNext"

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

Solution One

  1. Remove "type": "module" from package.json if it's added
  2. In tsconfig.json under the compilerOptions Set module property to CommonJS module: "CommonJS" and moduleResolution: "Node"

Solution Two

if the first one didn't work, or you have for some reason to keep module: "ESNext"

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

added 300 characters in body
Source Link

You have to do the following:

Solution One

  1. Remove "type": "module" from package.json if it's added
  2. In tsconfig.json under the compilerOptions Set module property to CommonJS module: "CommonJS" and moduleResolution: "Node"

Solution Two

if the first one didn't work, or you have for some reason to keep module: "ESNext"

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

You have to do the following:

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

Solution One

  1. Remove "type": "module" from package.json if it's added
  2. In tsconfig.json under the compilerOptions Set module property to CommonJS module: "CommonJS" and moduleResolution: "Node"

Solution Two

if the first one didn't work, or you have for some reason to keep module: "ESNext"

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

added 30 characters in body
Source Link

You have to do the following:

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add ts-node config and set esm to truethe following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

You have to do the following:

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add ts-node config and set esm to true

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

You have to do the following:

1- Add "type": "module" to package.json

2- Install ts-node npm i -g ts-node

3- Go to tsconfig.json and add the following:

{ "compilerOptions": { "module": "ESNext", "moduleResolution": "Node", /* ... your props ... */ }, "ts-node": { "esm": true } } 

4- Run ts-node fileName.ts

Source Link
Loading