cordova-plugman icon indicating copy to clipboard operation
cordova-plugman copied to clipboard

Plugin installation fails with a registry fetch error when run using through `execSync` and npm 8.15.0

Open fortinmike opened this issue 2 years ago • 0 comments

Bug Report

Problem

What is expected to happen?

Plugin installation should succeed.

What does actually happen?

Plugin installation fails with a registry fetch error (but the plugin is in the registry). It sometimes succeeds on the second try, as if the first time it didn't wait for the fetch to finish before making sure the plugin exists on disk. Installation of all plugins fails in the same manner, it's not just this one.

Information

Here is the error:

Running command: npm install [email protected] --production --no-save
Command finished with error code 0: npm install,[email protected],--production,--no-save
Failed to fetch plugin [email protected] via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:
added 1 package, removed 1 package, and audited 2 packages in 1s

found 0 vulnerabilities
CordovaError: Failed to fetch plugin [email protected] via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Could not determine package name from output:
added 1 package, removed 1 package, and audited 2 packages in 1s

found 0 vulnerabilities
    at /Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/[email protected]/node_modules/cordova-lib/src/plugman/fetch.js:146:43
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
node:child_process:915
    throw err;
    ^

Error: Command failed: node_modules/.bin/plugman -d install --platform android --project platforms/android --plugin [email protected] --plugins_dir=plugins
    at checkExecSyncError (node:child_process:841:11)
    at execSync (node:child_process:912:15)
    at /Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/scripts/install-plugins.js:29:5
    at arrayEach (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:530:11)
    at Function.forEach (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:9410:14)
    at /Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/scripts/install-plugins.js:28:5
    at /Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:3032:24)
    at Function.forOwn (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:13082:24) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 37257,
  stdout: null,
  stderr: null
}
 ELIFECYCLE  Command failed with exit code 1.

Workaround

It seems like the problem occurs because something goes wrong when plugman uses npm 8.5 while being run by execSync (in a script). If I install npm 6.X locally in the project (npm install --save-dev [email protected]), the plugman script uses that internally and installation succeeds. However, it forces me to downgrade npm to v6 for my whole project instead of staying on npm 8 which is the default for node 16.

Command or Code

execSync(
    `node_modules/.bin/plugman -d install --platform android --project platforms/android --plugin [email protected] --plugins_dir=plugins`,
    { stdio: "inherit" }
);

Environment, Platform, Device

macOS 12.6 (21G115)

Version information

node 16.17.1 npm 8.15.0 plugman 3.0.1 cordova 11.0.0 cordova-android 10.1.2 cordova-ios 6.2.0

Checklist

  • [x] I searched for existing GitHub issues
  • [x] I updated all Cordova tooling to most recent version
  • [x] I included all the necessary information above

fortinmike avatar Oct 10 '22 15:10 fortinmike