首页 文章

无法从本地文件夹添加cordova插件

提问于
浏览
2

我正在Ionic中创建一个示例应用程序 . 在从本地文件夹添加cordova插件到我的应用程序时,我得到以下错误:

cordova插件添加../local-cordova-plugin--save✖运行命令 - 失败! [错误]运行cordova插件时发生错误添加../local-cordova-plugin --save(退出代码1):错误:无法获得已安装模块的绝对路径

Note :如果我在从npm存储库添加插件或向我的应用添加任何平台后添加它,则会发生此错误 . 如果我先添加它,在添加任何其他插件或平台之前,它会成功添加 .

Steps to reproduce:

$ ionic cordova plugin add ../local-cordova-plugin

Note :在将npm存储库中的平台或插件添加到离子应用程序后添加本地cordova插件 .

Other information: 已发布similar issue但未解决我的问题 . 我使用了像 --nofetch, --force, --noregistry, --searchpath 这样的旗帜但没有帮助 .

Ionic info:


```java
@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

全球套餐:

Cordova CLI : 7.0.1

本地包裹:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

系统:

Android SDK Tools : 26.0.2
Node              : v7.0.0
npm               : 3.10.8 
OS                : macOS Sierra

Update :我的local-cordova-plugin的plugin.xml(根据@MaximShoustin的要求)

<?xml version='1.0' encoding='utf-8'?>
<plugin id="com.local.cordova" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
  <name>local_plugin</name>
  <js-module name="local_plugin" src="www/local_plugin.js">
    <clobbers target="local" />
  </js-module>
  <platform name="android">
    <config-file parent="/*" target="res/xml/config.xml">
      <feature name="local_plugin">
        <param name="android-package" value="com.local.cordova.local_plugin" />
      </feature>
    </config-file>
        <config-file parent="/*" target="AndroidManifest.xml">
    </config-file>
    <source-file src="src/android/local_plugin.java" target-dir="src/com/local/cordova/local_plugin" />
    <resource-file src="local-release/local-1.0.0-release.aar" target="libs/local-1.0.0-release.aar" />
    <edit-config file="AndroidManifest.xml" target="/manifest/uses-sdk" mode="merge">
        <uses-sdk android:minSdkVersion="19" />
    </edit-config>
  </platform>
</plugin>

1 回答

  • 1

    经过大量的搜索和冲浪,我得到了解决问题的方法 . 我查看了node_modules,并且有一个我想要安装的插件的文件/符号链接 . 一旦我删除了它,我就没有问题安装插件 .

相关问题