import "dotenv/config";
import express, { Request, Response, NextFunction } from "express";
import { createApi } from "unsplash-js";
import nodeFetch from "node-fetch";
import * as config from "./config";
const app = express();
const unsplash = createApi({
accessKey: config.accessKey,
fetch: nodeFetch as unknown as typeof fetch,
});
-
Observed Behaviour
C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\index.js:851
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\node-fetch\src\index.js from C:\Users\1\Desktop\portfolios\gallery\proxy\src\app.ts not supported.
Instead change the require of index.js in C:\Users\1\Desktop\portfolios\gallery\proxy\src\app.ts to a dynamic import() which is available in all CommonJS modules.
at Object.require.extensions.<computed> [as .js] (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\index.js:851:20)
at Object.<anonymous> (C:\Users\1\Desktop\portfolios\gallery\proxy\src\app.ts:32:38)
at Module.m._compile (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\index.js:857:29)
at Object.require.extensions.<computed> [as .ts] (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\index.js:859:16)
at phase4 (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\bin.js:466:20)
at bootstrap (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\bin.js:54:12)
at main (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\bin.js:33:12)
at Object.<anonymous> (C:\Users\1\Desktop\portfolios\gallery\proxy\node_modules\ts-node\dist\bin.js:579:5) {
code: 'ERR_REQUIRE_ESM'
}
Steps to Reproduce
src/app.ts
-
Observed Behaviour
-
Expected Behaviour
works fine
Technical Notes
package.json
tsconfig.json
works fine with
node-fetch ^2.6.5
but not working withnode-fetch ^3.2.9
-