Build Talking Apps for Alexa: node-fetch not loading (page 124)


When I try to run my skill I get the following error; what should I do?

“errorMessage”: “Must use import to load ES Module: /var/task/node_modules/node-fetch/src/index.js\nrequire() of ES modules is not supported.\nrequire() of /var/task/node_modules/node-fetch/src/index.js from /var/task/GoogleCalendarEventSaver.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.\nInstead rename index.js to end in .cjs, change the requiring code to use import(), or remove “type”: “module” from /var/task/node_modules/node-fetch/package.json.\n”,
“code”: “ERR_REQUIRE_ESM”,

I tried:
npm uninstall node-fetch
npm install node-fetch@2

That updated package.json in the developer console to:
“name”: “node-fetch”,
“version”: “2.6.7”,

But I got the same error message. :confounded:

Removed “module”: “lib/index.mjs”, from node-fetch package.json and that seemed to fix this problem