Development tools
As you'll make use of third-party modules of Node.js, you're going to need npm in order to download and install all the dependencies; so, Node.js (http://nodejs.org/) or io.js (https://iojs.org/) must be obviously installed in your development environment.
I know you cannot wait to write your first application, but before you start, I would like to introduce you to Sublime Text 2. It is a simple but sophisticated IDE, which, thanks to the support for custom build scripts, allows you to run (and debug) NW.js applications from inside the editor itself.
If I wasn't convincing and you'd rather keep using your favorite IDE, you can skip to the next section; otherwise, follow these steps to install and configure Sublime Text 2:
- Download and install Sublime Text 2 for your platform from http://www.sublimetext.com/.
- Open it and from the top menu, navigate to Tools | Build System | New Build System.
- A new edit screen will open; paste the following code depending on your platform:
- On Mac OS X:
{ "cmd": ["nwjs", "--enable-logging", "${project_path:${file_path}}"], "working_dir": "${project_path:${file_path}}", "path": "/Applications/nwjs.app/Contents/MacOS/" }
- On Microsoft Windows:
{ "cmd": ["nw.exe", "--enable-logging", "${project_path:${file_path}}"], "working_dir": "${project_path:${file_path}}", "path": "C:/Tools/nwjs/", "shell": true }
- On Linux:
{ "cmd": ["nw", "--enable-logging", "${project_path:${file_path}}"], "working_dir": "${project_path:${file_path}}", "path": "/home/userName/nwjs/" }
- On Mac OS X:
- Type Ctrl + S (Cmd + S on Mac) and save the file as
nw-js.sublime-build
.
Perfect! Now you are ready to run your applications directly from the IDE.
Tip
There are a lot of packages, such as SublimeLinter, LiveReload, and Node.js code completion, available to Sublime Text 2. In order to install them, you have to install Package Control first. Just open https://sublime.wbond.net/installation and follow the instructions.