Skip to content

[ERR_REQUIRE_ESM] #5088

Closed
Closed

Description

@712163

environment:
centos7.9 x64
node v16
axios 1.1.2

code:
const axios = require(__dirname + '/../node_modules/axios').default;
axios.defaults.withCredentials = true;
axios.get(...);

error:
2022-10-11T00:00:01: crontab_child_process_stderr: /home/card/libs/function_main.js:13
2022-10-11T00:00:01: const axios = require(__dirname + '/../node_modules/axios').default;
2022-10-11T00:00:01: ^
2022-10-11T00:00:01:
2022-10-11T00:00:01: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/card/node_modules/axios/index.js from /home/card/libs/function_main.js not supported.
2022-10-11T00:00:01: Instead change the require of index.js in /home/card/libs/function_main.js to a dynamic import() which is available in all CommonJS modules.
2022-10-11T00:00:01: at Object. (/home/card/libs/function_main.js:13:15)
2022-10-11T00:00:01: at Object. (/home/card/libs/class_admin.js:31:24)
2022-10-11T00:00:01: at Object. (/home/card/crontab.js:9:15) {
2022-10-11T00:00:01: code: 'ERR_REQUIRE_ESM'
2022-10-11T00:00:01: }

Activity

  1. jasonsaayman commented on Jul 30, 2025

    @jasonsaayman
    Member

    Thanks for your bug report, we will be closing this issue and ask that you please test and try re-create the issue with the latest version of Axios. If the bug is still present please open a issue. If possible and you are willing open a pull request with a proposed fix. Please see the motivation for doing this:

    #6983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions