'"require() of ES Module [...] is not supported" when using typescript
My setup is as follows:
I have a package.json file:
{
"name": "discord-app-test",
"version": "1.0.0",
"main": "src/index.ts",
"license": "ISC",
"scripts": {
"dev": "nodemon --exec \"yarn start\" --watch src --ext ts,json --ignore *.test.ts",
"start": "ts-node ."
},
"dependencies": {
"dotenv": "^10.0.0",
"node-fetch": "^3.0.0"
},
"devDependencies": {
"@types/node": "^16.11.6"
}
}
I have no tsconfig.json file as I never need it, normally. Though, somehow when using the node-fetch package, I get this error saying "require() of ES Module [...] is not supported" even though I am importing it with the ES6 syntax:
import fetch from 'node-fetch';
I have tried specifying "type": "module" in my package.json, but then I got the error "Unknown file extension ".ts" for [...]".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
