NativeScript / NativeScript/nativescript-cli

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

未關閉
#3,123 6 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug os: android plugins
主要語言
JavaScript
星號
1.1k
分支
204
平均合併
1 天 9 小時
30 天內合併 PR
8

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 lib/services/plugins-service.js 開始,特別查看 PluginsService.getInstalledFrameworkVersion 和 isPluginDataValidForPlatform,然後在示範應用程式中使用 tns plugin add ../src 重現問題。追蹤當應用程式的 package.json 缺少 tns-android 鍵時,file: 相依性的處理方式。完成的標準是:從本機目錄和 tarball 新增 plugin 時,在任一平台上都不再擲出 undefined-version 錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript
領域
cli
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。