Welcome to the Linux Foundation Forum!

Error [ERR_REQUIRE_ESM]: require() of ES Module

Options

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

Answers

  • baocongchen
    Options

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

  • davidmarkclements
    Options

    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.

Categories

Upcoming Training