Search code examples
cordova

Why node js is used for cordova?


Can anyone explain why nodejs is required to do android project using Apache Cordova? It would be great if I could get a little idea about it. Also what is the meaning of sudo npm install -g cordova


Solution

  • NPM is a really popular package manager for javascript applications in node, so its the natural choice for an installer tool for a javascript app framework. As Dawson says, its a CLI tool for generating a static collection of files/scripts and then running the scripts to get plugins/build/deploy your code. Lots of developers have NPM installed already, and its easy to install/update/version the CLI tool.

    So, to break down the installation command

    sudo gives you administrative privilages for the rest of the command so you have permission to install the files on a linux machine.

    npm install invokes the package manager for an installation

    -g installs the dependencies globally on your machine. Without this flag, whatever you install will just be installed in the local folder. You want your application specific dependencies installed locally, but your general development tools (npm, bower, grunt, etc) installed globally so you don't need to retrieve the files over and over.

    cordova is the name of the package to install.