I'm building a mobile app thanks to Cordova, and as Cordova is based on Node.js, I thought that I could use NPM packages into the app.
For example, I want my mobile app to talk to a remote MySQL database. I thought I could use the mysql NPM package (https://www.npmjs.org/package/mysql) in order to embed a MySQL driver into my mobile app, but I don't see any docs or tutos to install NPM packages into my mobile app.
So, is that possible to "embed" NPM packages into a Cordova app ? Is my app "architecture" bad ?
Thanks a lot for your help.
Regards, Sylvain
You can use node packages for development purposes like using grunt, bower, etc. but inside the app you have to use phonegap/cordova plugins.
You cannot use node modules in your phonegap app, because even if they are js files they require the Node.JS runtime to work and you cannot install or embed NodeJS on the mobile platforms.
But you can use any JS library that doesn´t not have a Node dependency, some I have used are moment.js, knockout.js, jquery, backbone.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With