Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins are not restored from package.json but only from config.xml #508

Open
3 tasks done
aidanas opened this issue Jun 21, 2020 · 3 comments
Open
3 tasks done

Plugins are not restored from package.json but only from config.xml #508

aidanas opened this issue Jun 21, 2020 · 3 comments

Comments

@aidanas
Copy link

aidanas commented Jun 21, 2020

Bug Report

Problem

Plugins are not restored from package.json. They are only restored if listed in config.xml but since Cordova 9 plugins are to be managed with package.json.
Steps to recreate:

  1. Create new app:
    cordova create testPluginRestore com.example.testpluginrestore TestPluginRestore
  2. Add platform:
    cordova platform add android
  3. Add plugin:
    cordova plugin add cordova-plugin-geolocation
  4. Check plugin added ok?
    cordova plugin ls Lists plugin OK. Also entry in package.json is present.
  5. Clean plugins and pltfroms
    rm -rf platforms/ plugins/ node_modules/
  6. Prepare android
    cordova prepare android
  7. Check plugins restored
    cordova plugin ls

What is expected to happen?

  • cordova-plugin-geolocation plugin to be restored and listed in the list

What does actually happen?

  • cordova-plugin-geolocation is not restored.

Information

The same behaviour was tested with other plugins cordova-plugin-camera,
cordova-plugin-firebase-dynamiclinks, and others with the same outcome.

Command or Code

Environment, Platform, Device

  • Mac OS

Version information

  • Cordova CLI 9.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@aidanas aidanas changed the title Plugins not restored from package.json but only from config.xml Plugins are not restored from package.json but only from config.xml Jun 21, 2020
@erisu
Copy link
Member

erisu commented Jun 24, 2020

@aidanas Can you please test with cordova@nightly and confirm if this is still an issue?

When I tested with nightly and it appears that plugins are being restored correctly.

rm -rf package-lock.json node_modules platforms plugins

$ cordova prepare
Warning: using prerelease version 10.0.0-nightly.2020.6.24.7b8e8678 ([email protected])
Discovered platform "android". Adding it to the project
Using cordova-fetch for [email protected]
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: com.test.foobar
	Name: foobar
	Activity: MainActivity
	Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]
Discovered plugin "cordova-plugin-whitelist". Adding it to the project
Installing "cordova-plugin-whitelist" for android
Discovered plugin "cordova-plugin-geolocation". Adding it to the project
Installing "cordova-plugin-geolocation" for android
Installing "cordova-plugin-compat" for android
Plugin doesn't support this project's cordova-android version. cordova-android: 8.0.0, failed version requirement:
      <6.3.0
Skipping 'cordova-plugin-compat' for android

$ cordova plugin ls
Warning: using prerelease version 10.0.0-nightly.2020.6.24.7b8e8678 ([email protected])
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-whitelist 1.3.4 "Whitelist"

The issue you are reporting might exist in 9.x but not in the upcoming 10.x release which is being prepared.

You can test with nightly by updating your global install:

npm uninstall -g cordova
npm install -g cordova@nightly

You might also be able to use npx command instead of upgrading your global install of Cordova.

In your Cordova project directory, you could try this:

rm -rf package-lock.json node_modules platforms plugins
npx cordova@nightly prepare

Please remember that nightly is not production ready as it has not been voted on for release.

@aidanas
Copy link
Author

aidanas commented Jun 29, 2020

@erisu, thanks for the heads up!
I can confirm that using Cordova 10 nightly build (10.0.0-nightly.2020.6.29.7b8e8678) it seems to restore plugins OK.

I get however Cannot find module 'properties-parser' error but that could be just broken nightly build or some other, potentially unrelated, issue on my end.

Aidanass-MBP:testPluginRestore aidanas$ npx cordova prepare android
Warning: using prerelease version 10.0.0-nightly.2020.6.29.7b8e8678 ([email protected])
Discovered platform "android". Adding it to the project
Using cordova-fetch for cordova-android@^8.1.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms/android
        Package: com.example.testpluginrestore
        Name: TestPluginRestore
        Activity: MainActivity
        Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]
Discovered plugin "cordova-plugin-whitelist". Adding it to the project
Installing "cordova-plugin-whitelist" for android
Discovered plugin "cordova-plugin-geolocation". Adding it to the project
Installing "cordova-plugin-geolocation" for android
Cannot find module 'properties-parser'
Aidanass-MBP:testPluginRestore aidanas$ cordova plugin ls
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-whitelist 1.3.4 "Whitelist"

Any ETA on Cordova 10 release dates?

@jfoclpf
Copy link

jfoclpf commented Mar 30, 2021

I have a lot of these issues also. Remove the platform Android before your step 5 where you remove those 3 directories, and then add platform again. Cordova prepare doesn't fetch npm modules and plugins, just cordova platform add.

In short, try this sequence

cordova platform rm android
rm -rf platforms/ plugins/ node_modules/
cordova platform add android

It should work on the latest version of cordova cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants