Unable to add a cordova plugin from local folder


I am creating a sample app in Ionic. On adding a cordova plugin to my app from local folder I get below error:

cordova plugin add ../local-cordova-plugin –save
✖ Running command – failed!
[ERROR] An error occurred while running cordova plugin add ../local-cordova-plugin –save (exit code 1):
Error: Failed to get absolute path to installed module

Note: This error occurs if I add it after I have added plugins from npm repository or adding any platform to my app. If I add it first, before adding any other plugin or platform, it gets added successfully.

Steps to reproduce:

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

Note: Add the local cordova plugin after adding a platform or a plugin from npm repository to your ionic app.

Other information:
There is a similar issue posted but it didn’t resolve my issue. I have used flags like --nofetch, --force, --noregistry, --searchpath but of no help.

Ionic info:

cli packages: (/usr/local/lib/node_modules)

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

global packages:

Cordova CLI : 7.0.1 

local packages:

@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: plugin.xml of my local-cordova-plugin (as requested by @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">
  <js-module name="local_plugin" src="www/local_plugin.js">
    <clobbers target="local" />
  <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" />
        <config-file parent="/*" target="AndroidManifest.xml">
    <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" />


After a lot of searching and surfing, I got the solution to my problem. I looked into node_modules and there is a file/symlink of the plugin I wanted to install. Once I removed that, I had no problem installing the plugin.

Answered By – Khusbu Mishra

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published