How to re-build existing plugin?


I need to add an appDelegate method to the nativescript-urlhandler plugin. I tried following the directions in the Building Plugins doc, but after cloning urlhandler repo there’s no publish folder. OK, so I copied the publish folder over from the seed plugin, but couldn’t get that to work either.

So, how can I add code to an existing plug-in? Yes, I’ll ultimately want to do a pull request and merge the code back, but right now I just want to get it working.


That plugin is not yet in align with latest seed project, check the src/package.json for available build and package commands.


@manojdcoder - yes I saw that, and found these lines:

"prebuild": "npm run tslint",
"build": "npm run ngc",
"tsc": "tsc",
"ngc": "node --max-old-space-size=8192 ./node_modules/.bin/ngc",
"tslint": "tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'",

So I cd’ed into the src folder and tried npm run ngc but received this message:

Error: Cannot find module '/Users/david/Documents/NativeScriptProjects/nativescript-urlhandler/src/node_modules/.bin/ngc'

Which makes sense, as there is no node_modules folder in the plugin package. And so, these leaves me back at my original question - how can I build this?


That simply happens when required node modules are not installed. I think it’s ngc-webpack module.


@manojdcoder - I really appreciate your responses - thanks for taking the time!

Yes, last night I realized I just needed to look at the dependencies in package.json. I cd’ed into the src folder and ran

tns plugin add nativescript-angular

and that added everything needed so I could successfully run the build command, npm run ngc. At, least, I think so.

I went back to my own project and ran

tns plugin remove nativescript-urlhandler 
tns plugin add ~/Documents/NativeScriptProjects/nativescript-urlhandler/src

Both commands ran successfully. But, I can’t tell if the code I added is receiving control or not. I added debugger and console.log statements in the code I added and the the other methods in the plugin file and none of them get triggered. My app behaves the same as it did before I added the code to the plugin.

So, now my question has evolved: how can I debug a plugin under development?

Alternatively, is there some other method I should be using to add the local plugin?


I never was able to debug the local plugin or even confirm that it was receiving control, but I was ultimately able to solve my problem by adding code to app.js and not modifying the plugin. Here’s the StackOverflow post on the topic.