In some cases it's necessary to include cordova plugins in your app repo. This is often the only option for private or custom plugins. Unfortunately, Cordova can have issues when restoring a local plugin from
config.xml. This usually presents with the following error in native builds during the
platform add step.
Failed to install 'your-plugin': CordovaError: Failed to fetch plugin ...
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Failed to get absolute path to installed module
The "Failed to get absolute path to installed module" message tells us that Cordova is unable to find the plugin in the location it expects. This can be corrected with the following steps.
Add a file named
.npmrc to the root of your project with the following contents.
- If your plugin is in a tarball (
.tgzfile) add the following to the scripts object in package.json.
"postinstall": "rm -rf node_modules/your-plugin||true"
- If your plugin is uncompressed in a sub directory of your project repo add the following to the scripts object in
"postinstall": "unlink node_modules/your-plugin||true"
This will suppress the creation of a
package-lock.json file and remove the module dir from
node_modules. When the
platform add step runs the module will be restored.
Be sure to delete any existing
package-lock.json file, add
.npmrc to the repo, and commit the change.