Defined Type: npm::install
- Defined in:
- puppet/modules/npm/manifests/install.pp
Overview
Define: npm::install
Custom resource for installing node.js module dependencies
Parameters
- directory
-
Name of the directory where to execute the install command
- environment
-
Extra environment variables to set when running npm install
- node_version
-
The Node version to use. Default: '12'
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'puppet/modules/npm/manifests/install.pp', line 15
define npm::install(
$directory,
$environment = [],
$node_version = '12',
) {
require ::npm
$nvm_dir = $::nvm::nvm_dir
$use_version = $node_version ? {
undef => $::nvm::node_version,
default => $node_version,
}
exec { "${title}_npm_install":
command => "/bin/bash -c 'source ${nvm_dir}/nvm.sh && nvm use ${use_version} && npm install'",#
user => 'vagrant',
cwd => $directory,
environment => [
"NVM_DIR=${nvm_dir}",
"NPM_CONFIG_CACHE=${::npm::cache_dir}",
'NPM_CONFIG_GLOBAL=false',
'LINK=g++',
'HOME=/home/vagrant',
] + $environment,
creates => "${directory}/node_modules",
logoutput => true,
}
}
|