apache / cordova-plugman

Apache Cordova Plugman
https://cordova.apache.org/
Apache License 2.0
400 stars 151 forks source link

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

Open fortinmike opened 1 year ago

fortinmike commented 1 year ago

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 cordova-plugin-navigationbar-color@0.1.0 --production --no-save
Command finished with error code 0: npm install,cordova-plugin-navigationbar-color@0.1.0,--production,--no-save
Failed to fetch plugin cordova-plugin-navigationbar-color@0.1.0 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 cordova-plugin-navigationbar-color@0.1.0 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/cordova-lib@9.0.1/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 cordova-plugin-navigationbar-color@0.1.0 --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/lodash@4.17.21/node_modules/lodash/lodash.js:530:11)
    at Function.forEach (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/lodash@4.17.21/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/lodash@4.17.21/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js:3032:24)
    at Function.forOwn (/Users/michael/Projects/Software/Simbioz/Ripple.Base/ripple/rcc/node_modules/.pnpm/lodash@4.17.21/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 npm@6.14), 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 cordova-plugin-navigationbar-color@0.1.0 --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