Open ath0mas opened 3 years ago
Could you please check if passing the option save: true
solves your issue?
await cordova.plugin('add', 'cordova-plugin-device', { save: true });
await cordova.plugin('add', 'cordova-plugin-androidx-adapter', { save: true });
await cordova.platform('add', 'android', { save: true });
@raphinesse adding the option save: true
solves the issue !! π
When using npm 6 I don't see any difference between with and without this option (mostly for dependencies fetched and stored), while using npm 7 it seems needed to add it π
Indeed this option seems to be set to true
using cli without options, and mostly none of --nosave
or --save
: cli.js#L447
I think this issue affects on a use-case when using Meteor 3 and cordova integration, Meteor 3 has built-in Node with a newer version of NPM. When installing a specific plugin with <dependency>
tag the issue mentioned here triggers and node_modules deps are lost.
As part of fixing this issue, I am trying to use the save
option as suggested here. However, I get this error:
=> Errors executing Cordova commands:
While adding platform Android to Cordova project:
Cordova error: CordovaError: Failed to fetch platform cordova-android
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
CordovaError: Error: Cannot find module 'cordova-android/package.json'
Do you know what could be the cause?
Bug Report
Problem
What is expected to happen?
For a cordova project created through cordova-lib node api, with npm@7, we expect the npm packages required by each cordova step/command to be stored and cumulated in _/nodemodules/ like what's done using npm@6 or with cordova-cli itself with npm@6 and npm@7.
What does actually happen?
Project creation has correct _/nodemodules/ and runs fine for
In those 3 cases, the order to add plugins and platform does not matter: plugins first and platform after them, or the opposite, platform first and then plugins.
π’ Using cordova-lib with npm@7 results in incomplete _/nodemodules/ and so possibly failing project creation (like when a plugin _afterprepare hook script called during
cordova platform add
does not find one of its own dependencies).Information
Again only since Npm 7, each step is fetching its packages correctly inside _/nodemodules/ but it is also like wiping its content first. Each call to
await cordova.plugin('add', pluginName);
orawait cordova.platform('add', platformName);
will result in its content to have only new deps for current specific plugin or platform.Command or Code
(simplified version of my code ; I am working on a basic and easily reusable project to share here soon)
will give such failure
Environment, Platform, Device
Version information
Checklist