apache / apache/cordova-cli

`cordova plugin add` is broken for tarballs

Open
#452 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
967
Forks
344
Avg merge
8h 41m
Merged PRs (30d)
9

Description

# Bug Report

## Problem

I can't install a plugin from a `.tgz` file created via `npm pack` in a plugin folder.

### What is expected to happen?

The plugin should be installed.

### What does actually happen?

```
λ cordova plugin add "..\..\Cordova\cordova-plugin-device\cordova-plugin-device-2.0.4-dev.tgz"
Invalid Plugin! ..\..\Cordova\cordova-plugin-device\cordova-plugin-device-2.0.4-dev.tgz needs a valid package.json
```

```
λ cordova plugin add ./cordova-plugin-device-2.0.4-dev.tgz --verbose
No scripts found for hook "before_plugin_add".
No version specified for ./cordova-plugin-device-2.0.4-dev.tgz, retrieving version from config.xml
No version for null saved in config.xml or package.json
Attempting to use npm info for null to choose a compatible release
Running command: npm view ./cordova-plugin-device-2.0.4-dev.tgz --json
Command finished with error code 0: npm view,./cordova-plugin-device-2.0.4-dev.tgz,--json
npm info for helloworld did not contain any engine info. Fetching latest release
Calling plugman.fetch on plugin "./cordova-plugin-device-2.0.4-dev.tgz"
Invalid Plugin! cordova-plugin-device-2.0.4-dev.tgz needs a valid package.json
CordovaError: Invalid Plugin! cordova-plugin-device-2.0.4-dev.tgz needs a valid package.json
at C:\Users\Jan\scoop\persist\nvm\nodejs\v12.6.0\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:78:43
at processTicksAndRejections (internal/process/task_queues.js:85:5)
```

Same happens on Mac as well.

## Information

### Version information

```
λ cordova -v
9.0.0 (cordova-lib@9.0.1)
```

## Checklist

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `cordova plugin add` using the `.tgz` examples, then inspect `node_modules/cordova-lib/src/plugman/fetch.js`, the entry point named in the stack trace. Confirm that a tarball created with `npm pack` is accepted as a plugin and installs successfully with its `package.json` recognized.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.