Registry / devops / cordova-fetch

cordova-fetch

JSON →
library5.0.0jsnpmunverified

A CLI tool for fetching Cordova plugins and platforms from Git repositories and npm registries. Currently at version 5.0.0, with low release cadence (last update ~2024). Key differentiator: integrates with Cordova's plugin/platform resolution logic, supporting semver and git references. Alternative to manual npm install or git clone for Cordova development.

npm install cordova-fetch
INSTALL
IMPORT
SIG · CORDOVA-FETCH
C
cordova-fetch
devopsjavascriptv5.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetch
✓ import fetch from 'cordova-fetch'
✗ const { fetch } = require('cordova-fetch')
Default export is a function; ESM-only since v5. CommonJS require returns undefined.
fetch (function)
✓ const fetch = require('cordova-fetch').default
✗ const fetch = require('cordova-fetch')
In CommonJS, use .default to get the function. Direct require gives an object without fetch.
getInfo
✓ import { getInfo } from 'cordova-fetch'
✗ import getInfo from 'cordova-fetch'
getInfo is a named export, not default. Use curly braces.

Shows how to fetch a Cordova plugin from npm (specified as package@version) into a local directory using the default export.

import fetch from 'cordova-fetch'; import path from 'path'; const destDir = path.resolve('./my-plugin'); const plugin = '@cordova-plugin/example@^1.0.0'; async function fetchPlugin() { try { const result = await fetch(plugin, destDir); console.log('Fetched plugin to:', result.path); } catch (err) { console.error('Fetch failed:', err.message); } } fetchPlugin();
Debug
Known issues
breakingv5 drops CommonJS main export; require() returns an object without the fetch function.
fix
Use import fetch from 'cordova-fetch' or const fetch = require('cordova-fetch').default.
affects: >=5.0.0
breakingNode.js 20+ and npm 8+ required; older versions not supported.
fix
Upgrade Node.js to >=20.9.0 and npm to >=8.1.0.
affects: >=5.0.0
deprecatedGit-based fetching via git:// or ssh:// URLs may be deprecated in future versions in favor of HTTPS.
fix
Use https:// git URLs instead of git:// or ssh://.
affects: >=5.0.0
gotchaWhen fetching from npm, the package must be accessible in the npm registry; private packages require authentication (npm login).
fix
Run npm login before fetching private packages.
affects: >=1.0.0
gotchaFetching a plugin with --link option fails if the source is not a local path.
fix
Ensure 'source' is a local directory when using --link.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: require(...).fetch is not a function
CommonJS require returns an object with no fetch property in v5.
fix
Use const fetch = require('cordova-fetch').default;
Error: fetch() got a spec that is not supported yet
Unsupported package specifier format (e.g., missing @scope/package).
fix
Use format like '@scope/plugin@version' or 'git+https://url.git'.
FetchError: request to https://registry.npmjs.org/... failed, reason: connect ECONNREFUSED
Network connectivity issue or registry unreachable.
fix
Check internet connection, proxy settings, and registry URL.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
cordova-commonrequiredProvides Cordova project parsing and helper utilities
npm-package-argrequiredParses npm package specifiers (e.g., version ranges, git URLs)
shelljsrequiredCross-platform shell commands for git operations
Agent activity
7 hits · last 30 days
node
6
Resources
cordova-fetch — npm install cordova-fetch · libregistry