Visit the free getting started tutorials on nativescript.org for JavaScript, Angular, or Vue.js.
Kindly note that we filter out plugins that:
package.json
$ tns plugin add @c4dt-nativescript-nodeify
Makes most npm packages compatible with NativeScript
fs
path
crypto
<app>/platforms/<ios|android>/.../tns_modules
browser
require()
main
left-pad
tns-core-modules
nativescript
From the command prompt go to your app's root folder and execute:
tns plugin add nativescript-nodeify
Include this in your code before requiring the problematic npm module.
require("nativescript-nodeify");
The demo tests a few popular libraries that depend on Node built-in modules which would normally not work in a NativeScript runtime environment.
Run the demo app from the root of the project: npm run demo.ios or npm run demo.android.
npm run demo.ios
npm run demo.android
This plugin isn't perfect, but it tried to solve issues for as many of the gazillion npm packages out there. A few issues are known, if yours is not in this list please create an issue.
global.location.protocol.search
To get you started with a few popular npm modules, here's some recipies. Please share your own by sending a PR to this repo!
All recipies assume you've already done:
$ tns create awssdk $ cd awssdk $ tns platform add ios $ tns platform add android $ tns plugin add nativescript-nodeify
node-uuid
$ npm install node-uuid --save
Boom! Done.
jsonwebtoken
$ npm install jsonwebtoken --save
Boom! Done. Again.
aws-sdk
amazon-cognito-identity-js
This one requires a bit more setup, but it's not too bad:
Never check in your AWS keys! Bots scan public repos and will create server instances you'll get billed for.
Depending on what you need:
$ npm install aws-sdk --save
or
$ npm install amazon-cognito-identity-js --save
To parse XML returned from AWS correctly (fi. when listing S3 bucket contents) we need to patch an additional library because the browser shim expects an.. ehm.. browser.
So open you app's package.json and add this nodeify node to the existing nativescript node:
nodeify
{ "nativescript": { "nodeify": { "package-dependencies": { "aws-sdk": [ { "xml/browser_parser": "xml/node_parser", "lib/node_loader": "lib/browser_loader" } ] } } } }
Then in your code for amazon-cognito-identity-js:
// require this to fix an issue with xhr event states require('nativescript-nodeify'); // register a user (here's a bit, but see the demo and https://github.com/aws/amazon-cognito-identity-js for details) var AmazonCognitoIdentity = require('amazon-cognito-identity-js'); var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool; var userPool = new CognitoUserPool({UserPoolId: 'foo', ClientId: 'bar'});
Now just use AWS as usual:
// then require AWS and interact with s3, dynamo, whatnot var AWS = require('aws');
Popularity metric based on:
Quality metric based on:
Maintenance metric based on: