Skip to main content

Using Local NPM modules

You can package an NPM module or Capacitor/Cordova plugin in your repository and reference it within your application.

To do so, you must package it as a tarball and reference the file path within your package.json.

For example, your project may have the following structure:

.
├── custom-plugins
│   └── my-custom-plugin
│   ├── package.json
│   └── src
├── package.json
└── src

From the root of your project, your module is located at custom-plugins/my-custom-plugin.

To package your plugin into a tarball, run npm pack inside the plugin's project directory.

$ cd custom-plugins/my-custom-plugin
$ npm pack

This will create my-custom-plugin-1.0.0.tgz inside custom-plugins/my-custom-plugin.

You can then reference this dependency in your package.json and utilize it in your app:

"dependencies": {
...
"my-custom-plugin": "file:custom-plugins/my-custom-plugin/my-custom-plugin-1.0.0.tgz",
...
}