hi @hrishikesh,
I’m getting the following error with the script you provided:
const Fetch = require('node-fetch')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\putin\Desktop\netlifydl\node_modules\node-fetch\src\index.js from C:\Users\putin\Desktop\netlifydl\index.js not supported.
Instead change the require of C:\Users\putin\Desktop\netlifydl\node_modules\node-fetch\src\index.js in C:\Users\putin\Desktop\netlifydl\index.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (C:\Users\putin\Desktop\netlifydl\index.js:3:15) {
code: 'ERR_REQUIRE_ESM'
}
When I tried changing const Fetch = require(‘node-fetch’) to const Fetch = import(‘node-fetch’), the script worked up to a point and printed the following error:
? Choose a deploy: 60700721258e817a0348c8ef
Fetching all files for the selected deploy...
C:\Users\putin\Desktop\netlifydl\index.js:78
Fetch(`https://api.netlify.com/api/v1/deploys/${deployID}/files`, {
^
TypeError: Fetch is not a function
at C:\Users\putin\Desktop\netlifydl\index.js:78:9
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Could you please help me figure this out?
Thank you!