Search code examples
javascriptcordovavisual-studio-2015twitter-oauthvisual-studio-cordova

How to add a javaScript library in Cordova visual studio?


I have been trying to use the twitter api on cordova visual studio, for this I need to use OAuth for authentication for requests. I would like to use the https://github.com/BoyCook/TwitterJSClient.git twitter client. The built in nuGet package manager does not have this library. How can I install this JS library in my cordova msvs?

I tried using npm on the command line to intall this library but I get this error. What does it mean? enter image description here


Solution

  • It looks like this javascript library is published on NPM: https://www.npmjs.com/package/twitter-node-client. To add this to your project, open the package.json file and put this in your dependencies section:

    "twitter-js-client": "0.0.5"

    You'll then see the "Dependencies" node in solution explorer say "(Restoring...)", and soon you'll see a node_modules folder appear in solution explorer. If you don't, turn on "show all files". This is what you should see:

    enter image description here

    You can then copy the library files into your www folder and consume them in your app (hopefully they work with Cordova!).