NPM is a JavaScript "package manager" that may be used, as shown below, to install the phonegap command line interface (cli). NPM itself is included with Node.js, which can be downloaded from https://nodejs.org/en/. The large number of tools and utilities available for coding in JavaScript can be very confusing for beginners. To clarify how some of these tools fit together, here is a short introduction.
JavaScript itself is a programming language, widely used to add interactive features to web pages. As its name suggests, JavaScript is a scripting language. Generally, programming languages are either scripting languages, like JavaScript, or compiled languages, of which C++ and Fortran are examples. Source code for compiled languages-- what is actually written by a programmer-- cannot be run directly, but must first be transformed into machine language. The compiled, machine language version of a program is referred to as object code. JavaScript source code, by contrast, does not have to be compiled, but is executed directly by the web browser.
JavaScript is typically used as a client side scripting language, which means that it runs on the end user's computer, or client. Thus, when you view a web page that contains JavaScript, the web server sends the actual JavaScript code to your web browser, which in turn runs the code. Server side scripts, by contrast, run on the computer (or computers) where the web page is stored (or created). A way to think about this is that with client side scripting, the web server sends instructions-- JavaScript code-- about how to display the web page, whereas with server side scripting, the server figures all that out and just sends the complete, finished web page.
Node.js is an alternative to web browsers for running JavaScript programs. Another way of saying this is that Node.js and web browsers are both JavaScript runtime environments. There are a few other runtime environments for JavaScript, but Node.js, aside from web browsers, is the one most widely used. As pointed out above, JavaScript is usually thought of as a client side scripting language, but when used with Node.js, it is often used as a server side language. For more information on Node.js, see https://nodejs.org/en/docs/guides/. There is also a good introduction in the Infoworld article, What is Node.js? The JavaScript runtime explained. It includes useful details on the nodejs.org "Getting started" pages as well as links to further info on many of the less familiar terms.
The Infoworld article also includes links to reviews of some other types of JavaScript tools and utilities, 6 best JavaScript IDEs and 10 best JavaScript editors. Per Wikipedia, an IDE, or integrated development environment, "is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools, and a debugger. Most modern IDEs have intelligent code completion." If you don't need all the features of an IDE, just a standalone editor may be more useful. My personal preference is for open source versions of both these tools, the Eclipse IDE and the Notepad++ editor.
Other terms you may encounter in reference to JavaScript tools and utilities are library, API, or application programming interface, and framework. These terms are used somewhat interchangeably. A library might be any collection of general purpose functions that can be reused in programs to perform common tasks, e.g., putting a list in alphabetic order, drawing simple shapes, or getting input from the user. Such a library may be referred to as an API, emphasizing that it provides a different way, presumably more easily understandable, to write programs. As an analogy, think of filing a tax return. If you just use the forms from the IRS, you have to do lots of addition and subtraction to fill out the forms correctly, and you have to enter the same information in many different places. On the other hand, if you use tax preparation software, you are presented with a much simpler set of screens-- an "interface"-- where you enter information just once, and the calculations are all done for you. A very large library or API may also be called a framework. Some programmers, however, reserve this term for a specific type of library, one that works like a large program controlling all the programs that use it, rather than just making functions available to programs as needed. The terminology is also complicated by the fact that many tools and utilities-- be they IDEs, APIs, frameworks, or whatever-- can be enhanced by numerous available plug-ins and add-ons, which are essentially libraries themselves. That said, two of the more popular JavaScript libraries, jQuery and AngularJS, are featured in tutorials on w3schools.com, a popular source of information on web development.
Once Node.js and NPM have been installed, NPM can be used to install the PhoneGap command line interface. PhoneGap is a tool that can be used to create mobile device apps using JavaScript as the programming language. The Windows command session below shows the installation of PhoneGap and some of the command line documentation available from the help command.
C:\Users\user>npm install -g phonegap npm WARN deprecated connect@2.30.2: connect 2.x series is deprecated npm WARN deprecated node-uuid@1.4.8: Use uuid module instead npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130 C:\Users\user\AppData\Roaming\npm\phonegap -> C:\Users\user\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\phonegap\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + phonegap@8.0.0 updated 5 packages in 26.854s C:\Users\user>phonegap Usage: phonegap [options] [commands] Description: PhoneGap command-line tool. Commands: help [command] output usage information create <path> create a phonegap project build <platforms> build the project for a specific platform install <platforms> install the project on for a specific platform run <platforms> build and install the project for a specific platform platform [command] update a platform version plugin [command] add, remove, and list plugins template [command] list available app templates info display information about the project serve serve a phonegap project version output version number push send test push notification (to a push-notification-compatible application) analytics turn analytics on or off, or view current status report-issue opens your browser and launches github.com with a ready to report issue Additional Commands: local [command] development on local system remote [command] development in cloud with phonegap/build prepare <platforms> copies www/ into platform project before compiling compile <platforms> compiles platform project without preparing it emulate <platforms> runs the project with the flag --emulator cordova execute of any cordova command Options: -d, --verbose allow verbose output -v, --version output version number -h, --help output usage information --no-update-notifier disable update notifier, to opt-out of update-notifier change the 'optOut' property to 'true' in ~/.config/configstore/update-notifier-phonegap.json Examples: $ phonegap help create $ phonegap create path/to/my-app $ cd my-app/ $ phonegap run ios $ phonegap analytics on C:\Users\user>phonegap help create Usage: phonegap create [options] <path> [id [name [config]]] Description: Creates a new application at the provided path. The application name and package ID can also be customized. These values are set in the app manifest (config.xml) and are used when creating a native project (platforms/<platform>/). The application can be created from an existing template as well. You can use any template that is published on npm, in your local file path, or available from a git URL. PhoneGap also recommends a few popular templates and provides shortened names for each. You can list the recommended templates with the `template list` command. The [config] option allows you to pass a JSON string, which will be injected into `<path>/.cordova/config.json`. Options: --name, -n <name> application name (default: "Hello World") --id, -i <package> package name (default: "com.phonegap.hello-world") --copy-from, -src <path> create project using a copy of an existing project --link-to <path> symlink/shortcut to the www assets without copying --template <npm package|path|git url> create app using template found on npm, your local path, or a git URL. Examples: $ phonegap create path/to/my-app $ phonegap create path/to/my-app "com.example.app" "My App" $ phonegap create path/to/my-app --id "com.example.app" --name "My App" $ phonegap create path/to/my-app --copy-from ../my-other-app $ phonegap create path/to/my-app --template hello-world $ phonegap create path/to/my-app --template phonegap-template-hello-world Also See: $ phonegap help template $ phonegap help template list C:\Users\user>phonegap help build Usage: phonegap build [<platforms>] [options] [-- [platform options]] Description: Builds your application for one or more specified platforms. When no platforms are specified, all installed platforms will be built. The build task will first prepare and then compile your application. If you want more control, you can individually prepare and compile your application with the commands. Options: --debug build in debug mode (default) --release build in release mode Experimental Options: --browserify plugin javascript is loaded into cordova.js Examples: $ phonegap build android $ phonegap build android ios $ phonegap build ios --release Also See: phonegap help prepare phonegap help compile C:\Users\user>phonegap help install Usage: phonegap install [<platforms>] [options] [-- [platform options]] DEPRECATED: This command has been deprecated and will soon be removed entirely. You should now use the `phonegap run <platform>` command. See `phonegap run help` to learn more about the command. Description: Installs the application for one or more specific platform. When no platform is specified, all platforms will be installed to target emulators or devices. Default action installs to a connected device, otherwise uses an emulator. Options: --device only install to a device --emulator, -e only install to an emulator Examples: $ phonegap local install android $ phonegap local install android --device C:\Users\user>phonegap help template Usage: phonegap template [command] Description: Create a new project from an existing template and list the templates available. Commands: list list recommended app templates search open npmjs.com to show all templates available Examples: $ phonegap template list $ phonegap template search $ phonegap create my-app --template hello-world C:\Users\user>phonegap help template list Usage: phonegap template list Description: Lists the availables templates to be used during the creation of an app. The template name can be supplied to the `create --template <name>` command to generate a new project using the specified template. The `<name>` can be a npm package, local file path, or git URL. Examples: $ phonegap template list Also See: $ phonegap help create $ phonegap help template C:\Users\user>phonegap template list blank A blank and empty PhoneGap app. csdk-image-editor A template for using the Creative Cloud Image Editor. hello-world Default hello world app for PhoneGap. framework7 Starter PhoneGap project for Framework7. push An example app for getting started with push notifications react-hot-loader Starter PhoneGap project using React.js, Babel, Webpack and Hot Reloading. star-track An example app using Framework7 and the Spotify API. webvr A WebVR and Google Cardboard demo ported from borismus/webvr-boilerplate. wikitude-augmented-reality Augmented Reality demo app powered by the Wikitude plugin C:\Users\user>
The session below shows the command and the resulting files for an app created from a template.
C:\Users\user>phonegap create my-app --template hello-world Creating a new cordova project. C:\Users\user>cd my-app C:\Users\user\my-app>dir Volume in drive C is OS Volume Serial Number is 7227-B6ED Directory of C:\Users\user\my-app 03/23/2018 01:53 PM <DIR> . 03/23/2018 01:53 PM <DIR> .. 03/23/2018 01:53 PM 1,229 .bithoundrc 03/23/2018 01:53 PM 8,379 config.xml 03/23/2018 01:53 PM 733 CONTRIBUTING.md 03/23/2018 01:53 PM <DIR> hooks 03/23/2018 01:53 PM <DIR> platforms 03/23/2018 01:53 PM <DIR> plugins 03/23/2018 01:53 PM 2,849 README.md 03/23/2018 01:53 PM <DIR> www 4 File(s) 13,190 bytes 6 Dir(s) 105,970,892,800 bytes free C:\Users\user\my-app>