Book Image

NW.js Essentials

Book Image

NW.js Essentials

Overview of this book

Table of Contents (17 chapters)
NW.js Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Working with Node.js modules


One of the strengths of Node.js is surely the availability of tens of thousands of modules that are freely downloadable with npm. As you probably know already, Node.js supports three kinds of modules:

  • Internal modules, which are parts of Node API

  • Third-party modules written in JavaScript

  • Third-party modules with C/C++ add-ons

You can use all of them in NW.js with some precautions.

Internal modules

Internal modules such as fs, path, or http are available out of the box and you can call them very easily with the following code:

var fs = require('fs');

Third-party modules written in JavaScript

Third-party JavaScript modules can be installed with npm and will be downloaded with all their dependencies inside the node_modules folder of the application's root folder in order to be shipped with the application. You can require them very easily using the following code:

var modulename = require('modulename');

Third-party modules with C/C++ add-ons

Even though most Node.js modules...