Open Rupanshy opened 6 days ago
I can't reproduce it:
echo '{"name": "test-package"}' > package.json
echo "require('howfat')" > index.js
npm i howfat axios@1.6.3
node index.js
Works with no issues, where axios@0.26.1 is installed correctly as the howfat's dependency:
test-package@/tmp/1 (27 deps, 3.53mb, 411 files, ©undefined)
├─┬ axios@1.7.7 (8 deps, 2.39mb, 149 files, ©MIT)
│ ├── follow-redirects@1.15.9 (29.22kb, 7 files, ©MIT)
│ ├─┬ form-data@4.0.1 (5 deps, 295.06kb, 49 files, ©MIT)
│ │ ├── asynckit@0.4.0 (26.72kb, 20 files, ©MIT)
│ │ ├─┬ combined-stream@1.0.8 (1 dep, 19.08kb, 11 files, ©MIT)
│ │ │ ╰── delayed-stream@1.0.0 (7.83kb, 6 files, ©MIT)
│ │ ╰─┬ mime-types@2.1.35 (1 dep, 218.57kb, 11 files, ©MIT)
│ │ ╰── mime-db@1.52.0 (200.72kb, 6 files, ©MIT)
│ ╰── proxy-from-env@1.1.0 (28.76kb, 7 files, ©MIT)
╰─┬ howfat@0.3.8 (18 deps, 1.16mb, 266 files, ©MIT)
├─┬ axios@0.26.1 (1 dep, 418.18kb, 57 files, ©MIT)
$ jq '.version' node_modules/howfat/node_modules/axios/package.json
"0.26.1"
$ jq '.version' node_modules/axios/package.json
"1.6.3"
Maybe someday I'll rewrite it to ESM, but I have no such a plan currently.
The howfat library is currently incompatible with axios@1.x because it uses the CommonJS require('axios') syntax in src/utils/http/HttpClient.js. Since axios@1.x has migrated to ES Modules (ESM), require('axios') is no longer supported and causes runtime errors.
Affected Code
In src/utils/http/HttpClient.js:
const { default: Axios } = require('axios');
This usage results in the following error when attempting to use axios@1.x:
Error [ERR_REQUIRE_ESM]: require() of ES Module is not supported
Steps to Reproduce Install howfat and axios@1.x in a Node.js project: npm install howfat axios@1.6.3 Attempt to use howfat in your code. Observe the runtime error indicating incompatibility with ES Modules.
Expected Behavior howfat should support axios@1.x by replacing the require('axios') syntax with the ES Modules import syntax:
import Axios from 'axios';
Proposed Solution Update all instances of require('axios') in the codebase to use import: import Axios from 'axios'; Update the package.json file to specify a peer dependency on axios@^1.0.0 to ensure compatibility: "peerDependencies": { "axios": "^1.0.0" }
Additional Context axios@1.x introduces security updates and new features, making it essential for modern applications to adopt. Many projects that rely on howfat may already be upgrading to axios@1.x, and this issue blocks their migration.
Request Please update the howfat codebase to support axios@1.x. If required, I’m happy to provide additional details or contribute a pull request to address this issue.
Environment Node.js Version: [e.g., 16.x or 18.x] Axios Version: 1.6.3 howfat Version: 0.3.8 Operating System: [e.g., macOS, Windows, or Linux]