Reputation: 85
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
Upvotes: 4
Views: 1742
Reputation: 2427
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.
Upvotes: 4
Reputation: 6029
sudo npm install -g cordova
is for installing the Cordova CLI. The CLI allows you to quickly create and build a base project so that you don't have to do any setup.
Once the project is built you can import it into the Android IDE of your choice and start working. However, cordova projects are mostly HTML/CSS/JS so most use an IDE better suited for that type of work and then continue to use the CLI for building and deploying the application.
You can use cordova without installing nodejs and the CLI by downloading the core project and adding to your own Android project.
Upvotes: 2