Version information
This version is compatible with:
- Puppet Enterprise 3.x
- Puppet >=3.4.0 < 4.0.0
- , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'jay-nodejs', '1.1.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-nodejs module
Table of Contents
- Overview
- Setup - The basics of getting started with nodejs
- Usage
- Npm packages
- Parameters
- Limitations - OS compatibility, etc.
- Development
Overview
The nodejs module installs the Node.js package, (global) npm package provider and configures global npm configuration settings. A defined type nodejs::npm is used for the local installation of npm packages.
By default this module installs packages from the NodeSource repository on Debian and RedHat platforms. The NodeSource Node.js package includes the npm binary, which makes a separate npm package unnecessary.
On SUSE, ArchLinux, FreeBSD, OpenBSD and Gentoo, native packages are used. On Darwin, the MacPorts package is used. On Windows the packages are installed via Chocolatey.
Setup
What nodejs affects:
- the Node.js package
- the npm package (if it exists as a separate package)
- the global npmrc file ($PREFIX/etc/npmrc)
- globally installed npm packages
- local npm packages installed in user-specified directories
Beginning with nodejs
To install Node.js and npm (using the NodeSource repository if possible):
class { 'nodejs': }
If you wish to install a Node.js 0.12.x release from the NodeSource repository rather than 0.10.x on Debian platforms:
class { 'nodejs':
repo_url_suffix => 'node_0.12',
}
Usage
When a separate npm package exists (natively or via EPEL) the Node.js development package also needs to be installed as it is a dependency for npm.
Install Node.js and npm using the native packages provided by the distribution: (Only applicable for Ubuntu 12.04/14.04 and Fedora operating systems):
class { '::nodejs':
manage_package_repo => false,
nodejs_dev_package_ensure => 'present',
npm_package_ensure => 'present',
}
Install Node.js and npm using the packages from EPEL:
class { '::nodejs':
nodejs_dev_package_ensure => 'present',
npm_package_ensure => 'present',
repo_class => '::epel',
}
npm packages
Two types of npm packages are supported:
- npm global packages are supported via the
npm
provider for the puppet package type. - npm local packages are supported via the Puppet defined type nodejs::npm.
For more information regarding global vs local installation see the nodejs blog
npm global packages
The npm package provider is an extension of the Puppet package type which supports versionable and upgradeable. The package provider only handles global installation:
For example:
package { 'express':
ensure => 'present',
provider => 'npm',
}
package { 'mime':
ensure => '1.2.4',
provider => 'npm',
}
npm local packages
nodejs::npm is used for the local installation of npm packages. It attempts to
support all of the npm install <package>
combinations shown in the
npm install docs
except version ranges. The title simply must be a unique, arbitary value.
- If using packages directly off the npm registry, the package parameter is the name of the package as published on the npm registry.
- If using scopes, the package parameter needs to be specified as '@scope_name/package_name'.
- If using a local tarball path, remote tarball URL, local folder, git remote URL or GitHubUser/GitRepo as the source of the package, this location needs to be specified as the source parameter and the package parameter just needs to be a unique, descriptive name for the package that is being installed.
- If using tags, the tag can be specified with the ensure parameter, and the package parameter needs to be match the name of the package in the npm registry.
- Package versions are specified with the ensure parameter, which defaults to
present
. - Install options and uninstall options are also supported, and need to be specified as an array.
- The user parameter is provided should you wish to run npm install or npm rm as a specific user.
nodejs::npm parameters:
- ensure: present (default), absent, latest, tag or version number.
- source: package source (defaults to a reserved value 'registry')
- target: where to install the package
- install_options: option flags invoked during installation such as --link (optional).
- uninstall_options: option flags invoked during removal (optional).
- npm_path: defaults to the value listed in
nodejs::params
- user: defaults to undef
Examples:
Install the express package published on the npm registry to /opt/packages:
nodejs::npm { 'express from the npm registry':
ensure => 'present',
package => 'express',
target => '/opt/packages',
}
or the lazy way:
nodejs::npm { 'express':
target => '/opt/packages',
}
Install the express package as user foo:
nodejs::npm { 'express install as user foo':
ensure => 'present',
package => 'express',
target => '/opt/packages',
user => 'foo',
}
Install a specific version of express to /opt/packages:
nodejs::npm { 'express version 2.5.9 from the npm registry':
ensure => '2.5.9',
package => 'express',
target => '/opt/packages',
}
Install the latest version of express to /opt/packages:
nodejs::npm { 'express latest from the npm registry':
ensure => 'latest',
package => 'express',
target => '/opt/packages',
}
Install express from GitHub to /opt/packages:
nodejs::npm { 'express from GitHub':
ensure => 'present',
package => 'express',
source => 'strongloop/express',
target => '/opt/packages',
}
Install express from a remote git repository to /opt/packages:
nodejs::npm { 'express from a git repository':
ensure => 'present',
package => 'express',
source => 'git+https://git@github.com/strongloop/expressjs.git',
target => '/opt/packages',
}
Install express from a remote tarball to /opt/packages:
nodejs::npm { 'express from a remote tarball':
ensure => 'present',
package => 'express',
source => 'https://server.domain/express.tgz',
target => '/opt/packages',
}
Install tagged packages:
nodejs::npm { 'my beta tagged package':
ensure => 'beta',
package => 'mypackage',
target => '/opt/packages',
}
Install a package from the registry associated with a specific scope:
nodejs::npm { 'package_name from @scope_name':
ensure => 'present',
package => '@scope_name/package_name',
target => '/opt/packages',
}
Install express from a local tarball to /opt/packages:
nodejs::npm { 'express from a local tarball':
ensure => 'present',
package => 'express',
source => '/local/repository/npm_packages/express.tgz',
target => '/opt/packages',
}
Install express with --save-dev --no-bin-links passed to npm install
:
nodejs::npm { 'express with options':
ensure => 'present',
package => 'express',
install_options => ['--save-dev', '--no-bin-links'],
target => '/opt/packages',
}
Uninstall any versions of express in /opt/packages regardless of source:
nodejs::npm { 'remove all express packages':
ensure => 'absent',
package => 'express',
target => '/opt/packages',
}
nodejs::npm::global_config_entry
nodejs::npm::global_config_entry can be used to set global npm configuration settings.
Examples:
nodejs::npm::global_config_entry { 'proxy':
ensure => 'present',
value => 'http://proxy.company.com:8080',
}
nodejs::npm::global_config_entry { 'dev':
ensure => 'present',
value => 'true',
}
Delete the key from all configuration files:
nodejs::npm::global_config_entry { 'color':
ensure => 'absent',
}
If a global_config_entry of proxy
or https-proxy
is specified, this will be
applied before the local installation of npm packages using nodejs::npm
.
Parameters
cmd_exe_path
Path to cmd.exe on Windows. Defaults to C:\Windows\system32\cmd.exe. You may need to change this parameter for certain versions of Windows Server.
legacy_debian_symlinks
As per a Debian Technical Committee resolution (CTTE #614907), newer
native packages on Debian/Ubuntu changed the path of the Node.js
executable from /usr/bin/node to /usr/bin/nodejs. The nodejs-legacy package
creates symlinks in the event that one is running applications that require
the previous name. Setting this parameter to true
recreates this behaviour.
The Node.js package in the NodeSource repository already creates this symlink
by default. This parameter defaults to false
.
manage_package_repo
Whether to manage an external repository and use it as the source of the
Node.js and npm package. Defaults to true
.
nodejs_debug_package_ensure
When set to present
or a version number, determines whether to install the
Node.js package with debugging symbols, if available. Defaults to absent
.
nodejs_dev_package_ensure
When set to present
or a version number, determines whether to install the
development Node.js package, if available. Defaults to absent
.
nodejs_package_ensure
When set to present
or a version number, determines whether to install the
Node.js package. Defaults to present
.
npm_package_ensure
When set to present
or a version number, determines whether to install the
separate npm package. When using the NodeSource repository, the Node.js
package includes npm, so this value defaults to absent
. This parameter will
need to be set to present
if you wish to use the native packages or are
using the EPEL repository.
npm_path
Path to the npm binary.
repo_class
Name of the Puppet class used for the setup and management of the Node.js
repository. Defaults to ::nodejs::repo::nodesource
(NodeSource).
If using the Node.js and npm packages from the EPEL repository, set this to
::epel
and make sure that the EPEL module is applied before the nodejs
module in your Puppet node definitions.
repo_enable_src
Whether any repositories which hold sources are enabled. Defaults to false
.
repo_ensure
Whether to ensure that the repository exists, if it is being managed. Defaults
to present
and may also be set to absent
.
repo_pin
Whether to perform APT pinning to pin the Node.js repository with a specific
value. Defaults to false
.
repo_priority
Whether to set a Yum priority for the Node.js repository. If using EPEL and
the NodeSource repository on the same system, you may wish to set this to a
value less than 99 (or the priority set for the EPEL repository) to ensure
that the NodeSource repository will always be preferred over the Node.js
packages in EPEL, should they both hold the same Node.js version. Defaults to
absent
.
repo_proxy
Whether to use a proxy for this particular repository. For example,
http://proxy.domain . Defaults to absent
.
repo_proxy_password
Password for the proxy used by the repository, if required.
repo_proxy_username
User for the proxy used by the repository, if required.
repo_url_suffix
This module defaults to installing the latest NodeSource 0.10.x release on
Debian platforms. If you wish to install a 0.12.x release you will need to
set this parameter to node_0.12
instead.
use_flags
The USE flags to use for the Node.js package on Gentoo systems. Defaults to ['npm', 'snapshot'].
Limitations
This module has received limited testing on:
- CentOS/RHEL 5/6/7
- Debian 7
- Fedora 20/21
- Ubuntu 10.04/12.04/14.04
The following platforms should also work, but have not been tested:
- Amazon Linux
- Archlinux
- Darwin
- Debian 8
- FreeBSD
- Gentoo
- OpenBSD
- OpenSuse/SLES
- Windows
This module is not supported on Debian Squeeze.
Module dependencies
This module uses treydock-gpg_key
for the import of RPM GPG keys. If using
an operating system of the RedHat-based family, you will need to ensure that
it is installed.
This modules uses puppetlabs-apt
for the management of the NodeSource
repository. If using an operating system of the Debian-based family, you will
need to ensure that puppetlabs-apt
version 2.x is installed.
If using CentoOS/RHEL 5, you will need to ensure that the stahnma-epel
module is installed.
If using CentoOS/RHEL 5/6/7 and you wish to install Node.js from EPEL rather
than from the NodeSource repository, you will need to ensure stahnma-epel
is
installed and is applied before this module.
If using Gentoo, you will need to ensure gentoo-portage
is installed.
If using Windows, you will need to ensure that chocolatey-chocolatey
is
installed.
nodejs::npm has the ability to fetch npm packages from Git sources. If you
wish to use this functionality, Git needs to be installed and be in the
PATH
.
Development
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
Read the complete module contribution guide
2015-06-23 Release 1.1.0
Backwards-incompatible changes
nodejs::repo::nodesource::apt is now compatible with puppetlabs-apt 2.x only
Summary
Debian-based platforms now require puppetlabs-apt 2.x rather than puppetlabs-apt 1.x
2015-05-20 Release 1.0.0
Summary
Module donated by Puppetlabs to Puppet Community. This release fixes support for ArchLinux, since npm recently moved to its own package.
2015-05-12 Release 0.8.0
Backwards-incompatible changes
- Puppet versions below 3.4.0 are no longer supported
- Debian Squeeze and Fedora version 18 and below are explicitly no longer supported
- Parameter naming changes to node_pkg, npm_pkg, dev_pkg, manage_repo, dev_pkg to approximate equivalents: nodejs_package_name, npm_package_name, nodejs_dev_package_name, manage_package_repo, nodejs_dev_package_ensure
- RedHat-family operating systems now use the NodeSource repository by default rather than the Fedora People repositories
- Debian Wheezy now uses the NodeSource repository by default rather than the Debian Sid repository
- The proxy parameter has been removed. Equivalent functionality can be obtained by using the nodejs::npm::global_config_entry defined type
- The version parameter has been removed. The approximate equivalent is nodejs_package_ensure (or nodejs_dev_package_ensure)
- The nodejs::npm defined type title is now an arbitary unique string rather than 'destination_dir:package'. The same functionality is now done with the target and package parameters.
- The nodejs::npm version parameter has been removed. The same functionality can now be performed with the ensure parameter
- Parameter naming changes to install_opt, remove_opt in nodejs::npm to approximate equivalents install_options and uninstall_options. Both must now be an array of strings and not strings.
Summary
This release performs major API changes and defaults to using the NodeSource repository where possible.
Features
- Defaults to using the NodeSource repositories where possible, but allows native packages to be installed when appropriate parameters are set
- Introduces a parameter repo_class, which allows one to use alternative repositories like EPEL for the Node.js packages
- Adds Windows installation support via Chocolatey
- Adds FreeBSD and OpenBSD installation support
- Adds tag and scope support to the defined type nodejs::npm
- Adds a defined type nodejs::npm::global_config_entry, which allows one to set and delete global npm config options
Bugfixes
- Supercedes PRs 99 (MODULES-1075), 97, 96, 94, 93, 85, 82, 80, 79, 51, 69, 66 and 102
- apt: update. pin to version. change key to 40 characters.
- Debian: Handle NodeSource. Improve Repository handling.
- windows: dont use deprecated chocolately module.
- testing: Pin RSpec version.
2015-01-21 - Release 0.7.1
Summary
This fixes the incorrect application of https://github.com/puppetlabs/puppetlabs-nodejs/pull/70 so that the code will actually run.
2015-01-20 - Release 0.7.0
Summary
This release adds some new features and improvements, including archlinux support and improved ubuntu support.
Features
- Add max_nesting parameter to npm list json parse
- Replace Chris's PPA with the Nodesource repo
- Parameterize package names
- Add archlinux support
- TravisCI updates
Bugfixes
- Fix proxy config requiers for Ubunutu
- Fix rspec tests
- Fix typo in README.md
2014-07-15 - Release 0.6.1
Summary
This release merely updates metadata.json so the module can be uninstalled and upgraded via the puppet module command.
2014-06-18 - Release 0.6.0
Summary
This release primarily has improved support for Gentoo and testing improvements.
Features
- Improved Gentoo support.
- Test updates
2014-03-20 - Release 0.5.0
Summary
This release is just a wrap up of a number of submitted PRs, mostly around improvements to operating system support, as well as some improvements to handling npm.
Features
- Update travis to test more recent versions of Puppet.
- Changed package name for Amazon Linux.
- Add support for Scientific Linux.
Bugfixes
- Ubuntu uses uppercase for the operatingsystem fact.
- Ignore exit codes from "npm list --json" as they can be misleading, and instead just parse the JSON.
- Set $HOME for npm commands.
- Don't include development version accidently.
- Fix for chrislea ppa that already installs npm.
2013-08-29 - Release 0.4.0
Summary
This release removes the precise special handling and adds the ability to pass in $version.
Features
- Precise uses the same ppa as every other release.
- New parameters in nodejs:
version
: Set the version to install.
2013-08-01 - Release 0.3.0
Summary
The focus of this release is ensuring the module still works on newer distributions.
Features
- New parameters in nodejs:
manage_repo
: Enable/Disable repo management.
Bugfixes
- Fixed npm on Ubuntuwhen using Chris Lea's PPA
- Make RHEL6 variants the default.
- Fix yumrepo file ordering.
Release 0.2.1 2012-12-28 Puppet Labs info@puppetlabs.com
- Updated EL RPM repositories
Release 0.2.0 2012-05-22 Puppet Labs info@puppetlabs.com
- Add RedHat family support
- Use npm package instead of exec script.
- Remove ppa repo for Ubuntu Precise.
Release 0.1.1 2012-05-04 Puppet Labs info@puppetlabs.com
- Use include for apt class and add spec tests.
Release 0.1.0 2012-04-30 Puppet Labs info@puppetlabs.com
- Initial module release.
Dependencies
- puppetlabs/stdlib (>=4.1.0 <5.0.0)
Copyright (C) 2012 Puppet Labs Inc Puppet Labs can be contacted at: info@puppetlabs.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.