NativeScript / NativeScript/nativescript-cli

`tns plugin add` fails when tns-android key is missing in package.json of the app

Open
#3,123 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug os: android plugins
Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

Did you verify this is a real problem by searching

Yes, here.

Tell us about the problem

I do a lot of plugin development ;-) I tend to do
tns plugin add ../src or tns plugin add pluginname-1.0.0.tgz
All of these will cause nativescript to throw a error

TypeError: Cannot read property 'version' of undefined
    at PluginsService.getInstalledFrameworkVersion (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:261:29)
    at PluginsService.isPluginDataValidForPlatform (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:265:48)
    at PluginsService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:57:26)
    at next (native)
    at /usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:7:71
    at __awaiter (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:3:12)
    at action (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:56:83)
    at PluginsService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:253:27)
    at next (native)
    at /usr/local/lib/node_modules/nativescript/lib/services/plugins-service.js:7:71

The issue is inserted in the package.json: "nativescript-pluginname": "file:<path to dir>",

When you attempt to get version numbers, "file:....." doesn't match and causes the above error.

Which platform(s) does your issue occur on?

Both

Please provide the following version numbers that your issue occurs with:

At least since TNS 3.0, still happening in 3.2

Please tell us how to recreate the issue in as much detail as possible.

tns plugin add ../src from a demo folder

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/services/plugins-service.js, especially PluginsService.getInstalledFrameworkVersion and isPluginDataValidForPlatform, then reproduce with tns plugin add ../src from a demo app. Trace how the file: dependency is handled when the app package.json lacks a tns-android key. Done means local-directory and tarball plugin additions no longer throw the undefined-version error on either platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.