Capacitor add Plugin from local Folder

I have followed the docs here, https://capacitor.ionicframework.com/docs/plugins/ and made a plugin.

Is there any way I can use this plugin without publishing it to npm? How can I locally add a capacitor plugin

1 Like

I haven’t tried it with a Capacitor plugin, but generally you can install local packages with npm install <folder>, where <folder> is a local folder on your machine. See https://docs.npmjs.com/cli/install

1 Like

I also didn’t use Capacitor but with Cordova this is possible via ionic cordova <path-to-folder>. I think this should be possible with the Capacitor command too.

1 Like

Hello,

I’m having problems with this too. How did you develop your custom plugin in a real Ionic project?

I’m trying to develop a custom Capacitor plugin in a directory called ā€œlocal_modulesā€ similar to ā€œnode_modulesā€ but, after installing it with npm install <path to module>, I get the following error when importing:

Cannot find module ā€˜module-name’.ts(2307)

Thanks,

Did you build the plugin? Run npm build in the local capacitor plugin folder, then try installing it. It worked for me.

1 Like

Thank you! That was the problem. When running npm build some additional files are generated and then it works. :slightly_smiling_face:

You can also use the npm link function in npm.

https://docs.npmjs.com/cli/link