axios-curlirize icon indicating copy to clipboard operation
axios-curlirize copied to clipboard

Node 14, AC 2.0.0: error: Must use import to load ES Module

Open jcollum-nutrien opened this issue 2 years ago • 0 comments

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/[email protected]/work/seed-association-service/node_modules/axios-curlirize/src/main.js
require() of ES modules is not supported.
require() of /Users/[email protected]/work/seed-association-service/node_modules/axios-curlirize/src/main.js from /Users/[email protected]/work/seed-association-service/dist/dao.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.
Instead rename main.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/[email protected]/work/seed-association-service/node_modules/axios-curlirize/package.json.
// dao.ts
import axios from 'axios';
...
import curlirize from 'axios-curlirize';
console.log(curlirize); // this line was suggested in a different ticket
// curlirize(axios); // using this instead didn't change the error
$ versions
Node v14.19.1
NPM 6.14.16
Yarn 1.22.18
OS:
ProductName:	macOS
ProductVersion:	12.5.1
BuildVersion:	21G83
$ cat package.json | grep "axios"
        "axios": "~0.27.2",
        "axios-curlirize": "~2.0.0",
        "@types/axios-curlirize": "~1.3.2",

jcollum-nutrien avatar Aug 22 '22 19:08 jcollum-nutrien