Welcome to the Linux Foundation Forum!

Error [ERR_REQUIRE_ESM]: require() of ES Module

put const got = require('got') under the routes/root.js fastify project, get the error shown in the headline. any idea?

Answers

  • Please downgrade got to version 11 in order to use it. npm uninstall got, followed by npm install got@11.

  • correct got has dropped support for CJS. The content has been update to install 11. In the future we'll be using fetch in the material since Node 18 will be providing a global fetch.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training