This is a migrated thread and some comments may be shown as answers.

Using NativeScript Plugins with AppBuilder

1 Answer 59 Views
AppBuilder Windows client
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ian
Top achievements
Rank 1
Ian asked on 26 Nov 2015, 05:34 PM

Hi,

Has anybody got an NPM plugin with NativeScript working with AppBuilder yet? I’ve used the ‘Manage packages’ screen in AB to include the nativescript-ios-uuid plugin in my app and the plugin is correctly listed as a dependency in the app’s packages.json file. However, when I use require("nativescript-ios-uuid") in my code I get a ‘Failed to find module’ runtime error.

I’ve tried require("../nativescript-ios-uuid") and numerous other path options but no luck. Does anybody know what the correct path should be to 'require' a {N} plugin?

Thanks, Ian

1 Answer, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 27 Nov 2015, 03:57 PM
In case it helps somebody else, I worked out what was going wrong here. The nativescript-ios-uuid plugin only works on iOS devices and you have to be careful to ensure that you both ‘require’ the plugin AND call its getUUID() method ONLY on an iOS device.

That's why the following code generated the ‘File not found’ error on iOS platforms:
var plugin = require("nativescript-ios-uuid");
if (page.ios) {
    var deviceId = plugin.getUUID();
}

However, this works on iOS:
if (page.ios) {
    var plugin = require("nativescript-ios-uuid");
    var deviceId = plugin.getUUID();
}
Regards, Ian
Tags
AppBuilder Windows client
Asked by
Ian
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Share this question
or