fabtools.nodejs

Node.js

This module provides tools for installing Node.js and managing packages using npm.

fabtools.nodejs.install_from_source(version='0.10.13', checkinstall=False)[source]

Install Node JS from source.

If checkinstall is True, a distribution package will be built.

import fabtools

# Install Node.js
fabtools.nodejs.install_nodejs()

Note

This function may not work for old versions of Node.js.

fabtools.nodejs.version(node='node')[source]

Get the version of Node.js currently installed.

Returns None if it is not installed.

fabtools.nodejs.install_package(package, version=None, local=False, npm='npm')[source]

Install a Node.js package.

If local is True, the package will be installed locally.

import fabtools

# Install package globally
fabtools.nodejs.install_package('express')

# Install package locally
fabtools.nodejs.install_package('underscore', local=False)
fabtools.nodejs.install_dependencies(npm='npm')[source]

Install Node.js package dependencies.

This function calls npm install, which will locally install all packages specified as dependencies in the package.json file found in the current directory.

from fabric.api import cd
from fabtools import nodejs

with cd('/path/to/nodejsapp/'):
    nodejs.install_dependencies()
fabtools.nodejs.package_version(package, local=False, npm='npm')[source]

Get the installed version of a Node.js package.

Returns None``is the package is not installed. If *local* is ``True, returns the version of the locally installed package.

fabtools.nodejs.update_package(package, local=False, npm='npm')[source]

Update a Node.js package.

If local is True, the package will be updated locally.

fabtools.nodejs.uninstall_package(package, version=None, local=False, npm='npm')[source]

Uninstall a Node.js package.

If local is True, the package will be uninstalled locally.

import fabtools

# Uninstall package globally
fabtools.nodejs.uninstall_package('express')

# Uninstall package locally
fabtools.nodejs.uninstall_package('underscore', local=False)