couchdb-nano icon indicating copy to clipboard operation
couchdb-nano copied to clipboard

Request for ETA on New Release Supporting Axios 1.x Version

Open Rupanshy opened this issue 1 year ago • 3 comments

The nano library is currently incompatible with [email protected] because it uses the CommonJS require('axios') syntax in lib/nano.js. Since [email protected] has transitioned to ES Modules (ESM), this usage results in runtime errors when attempting to use the library with [email protected].

Affected Code

In lib/nano.js:

const axios = require('axios'); This usage causes the following error when running the code with [email protected]:

Error [ERR_REQUIRE_ESM]: require() of ES Module is not supported

Steps to Reproduce Install nano and [email protected] in a Node.js project: npm install nano [email protected] Import or require nano in your code: const nano = require('nano'); Attempt to use nano to make an HTTP request. Observe the runtime error indicating incompatibility with ES Modules.

Expected Behavior nano should support [email protected] 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 [email protected] includes critical security updates and new features, making its adoption essential for projects aiming to maintain secure and modern applications. The current incompatibility blocks projects from upgrading to [email protected] if they depend on nano.

Request Please update the nano codebase to support [email protected]. If needed, I am happy to assist with additional details or contribute a pull request to resolve the issue.

Environment Node.js Version: [e.g., 16.x or 18.x] Axios Version: 1.6.3 nano Version: [e.g., 9.x] Operating System: [e.g., macOS, Windows, or Linux]

Rupanshy avatar Nov 15 '24 04:11 Rupanshy

Dear Maintainers, I hope this message finds you well. I wanted to follow up on the issue I raised regarding the nano package's compatibility with [email protected] due to the use of CommonJS syntax (require('axios')) in lib/nano.js. As highlighted earlier, projects relying on nano face runtime errors when attempting to upgrade to [email protected], which has transitioned to ES Modules (ESM). This has become a critical blocker, particularly for teams needing to address vulnerabilities in earlier versions of Axios (e.g., 0.28.x). Recap of the Issue Problem: require('axios') is incompatible with Axios 1.x, leading to runtime errors. Expected Behavior: nano should support Axios 1.x by transitioning to ESM syntax: import axios from 'axios'. Proposed Solution: Update the nano codebase to use import instead of require and declare axios@^1.0.0 as a peer dependency. Why This is Critical Security: Many organizations, including mine, are required to address vulnerabilities in earlier Axios versions. Ecosystem Alignment: Upgrading to Axios 1.x ensures compatibility with other modern libraries and benefits from performance improvements and security patches. Request for Update I understand that maintaining open-source projects requires significant time and effort, and I deeply appreciate the work you’ve done on nano. However, I’d like to inquire: Is there a timeline for addressing this compatibility issue? If assistance is needed, I’d be happy to contribute a pull request to help update the codebase for Axios 1.x compatibility.

Rupanshy avatar Jan 21 '25 14:01 Rupanshy

Curious if axios support is actually necessary, versus migrating out of that entirely and using fetch?

Have been considering that but have not yet assessed how deep a dependency axios is.

Have only been loving CouchDB and implementing nano for a few quarters, so I am sure someone else would know better.

If this is a stuck issue and someone can provide the insight above, I can see about removing axios support, or upgrading it.

Update: I see votes for fetch https://github.com/apache/couchdb-nano/issues/307

digitalextremist avatar Aug 29 '25 15:08 digitalextremist

Now moot per #314

digitalextremist avatar Sep 10 '25 13:09 digitalextremist