Install Node.js modules

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

Node.js comes with the npm package manager. Using it, you can install, uninstall and search for Node.js modules.

npm installs modules in two different scopes: local and global.

Local installation

The local installation is recommended, as the size of the packages is usually small. It installs the packages in a node_modules subdirectory of the current working directory, usually a project folder. This ensures all the required dependencies are installed and won’t break when installing other packages in a different project or locally.

To install modules locally, you just have to execute this command:

$ npm install PACKAGE

For example, to install MySQL, you would execute:

$ npm install mysql

Global installation

In other cases (typically when the module installs a command line tool), it is more convenient to install the packages globally. In these cases, the command varies slightly:

$ sudo npm -g install PACKAGE

For example, to install Express, you would execute:

$ sudo npm -g install express

This will make the Express command-line available in all projects.

We recommend installing packages in both local and global modes, so that you can share installed commands and still protect the dependencies of your project.

Last modification April 8, 2020