Using NPM packages in PebbleKit JS apps
It’s easy to use an Node.js module that you have installed in your PebbleKit JS-enabled application:
-
Install Browserify:
npm install -g browserify
-
Require your favorite NPM packages and use:
var xml2js = require('xml2js'); Pebble.addEventListener("ready", function (e) { var xml = "Hello xml2js!" xml2js.parseString(xml, function (err, result) { console.log(result.root); }); });
-
Let Browserify compile all of your packages into a single file:
browserify my-file.js -o pebble-js-app.js