I googled for a while but I could not find a solution that fixed my issue.
I want to use the fetch function from "node-fetch", but when requiring it in my code, I get the error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/xvma/stuff/Projekte/React/first-try/node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
require() of /Users/xvma/stuff/Projekte/React/first-try/node_modules/node-fetch/src/index.js from /Users/xvma/stuff/Projekte/React/first-try/test.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/xvma/stuff/Projekte/React/first-try/node_modules/node-fetch/package.json.
In this file I want to use fetch()
I hope you guys can help me, I tried deleting my node-components folder & package lock but that did not work. Also, in my package.lock.json "type"="module" is not set.