Giter Site home page Giter Site logo

willdurand / puppet-nodejs Goto Github PK

View Code? Open in Web Editor NEW
68.0 4.0 54.0 376 KB

Puppet module to manage Node.js and NPM that just works.

Home Page: http://forge.puppetlabs.com/willdurand/nodejs

License: MIT License

Ruby 66.88% Puppet 32.34% HTML 0.32% Nix 0.47%

puppet-nodejs's Introduction

puppet-nodejs

Build Status Puppet Forge Puppet Forge - downloads Coverage Status

This module allows you to install Node.js and NPM. This module is published on the Puppet Forge as willdurand/nodejs.

Announcements

  • The latest release is 2.1.

  • On master development is happening for 2.2.

  • Legacy 1.9 is still maintained, but won't receive any new features.

  • For further information, please look at the Support chapter.

Installation

The module depends on the following well-adopted and commonly used modules:

The easiest approach to install this module is by using r10k:

forge 'http://forge.puppetlabs.com'

mod 'willdurand/nodejs', '2.0.3'
mod 'puppetlabs/stdlib', '5.1.0'

Usage

Deploying a precompiled package

There are a few ways to use this puppet module. The easiest one is just using the class definition and specify a value for the version to install.

class { 'nodejs':
  version => latest,
}

This installs the latest precompiled version available on nodejs.org/dist. node and npm will be available in your $PATH at /usr/local/bin.

There are several ways to specify a target version of node:

  • version => latest installs the latest version available.
  • version => lts installs the latest long-term support version.
  • version => '9.x' installs the latest version from the v9 series.
  • version => '9.7 installs the latest 9.7 patch release.
  • version => '9.9.0' installs exactly this version.

Compiling from source

In order to compile from source with gcc, the make_install option must be true.

class { 'nodejs':
  version      => 'lts',
  make_install => true,
}

Using a custom source

It's also possible to deploy NodeJS instances to Puppet nodes from your own server. This can be helpful when e.g. distributing your own, patched version of NodeJS.

The source can be specified like this:

class { '::nodejs':
  source => 'https://example.org/your-custom-nodejs-binaries.tar.gz',
}

It's also possible to compile the custom instance from source which is helpful when e.g. deploying a patched NodeJS:

class { '::nodejs':
  source       => 'https://example.org/node-11.0.0.tar.gz',
  make_install => true,
}

Please note that the source needs to be a compressed tarball, but it doesn't matter which format is in use (.xz,.gz etc). However additional packages such as xz-utils for Debian have to be installed manually if needed (e.g. when providing a custom source which is bundled as .tar.xz).

Setup with a given download timeout

Due to infrastructures with slower connections the download timeout of the nodejs binaries can be increased or disabled:

class { '::nodejs':
  download_timeout => 0,
}

For further information please refer to the timeout docs in Puppet.

Setup multiple versions of Node.js

If you need more than one installed version of Node.js on your machine, you can configure them using the instances list.

class { '::nodejs':
  version => lts,
  instances => {
    "node-lts" => {
      version => lts
    },
    "node-9" => {
      version => '9.x'
    }
  },
}

This will install the three specified versions (latest version, current LTS version and latest 9.x of NodeJS) in /usr/local/node.

Important is that the default node and npm executable's versions need to be specified as hash in the instances list.

The structure of linked executables in /usr/local/bin will look like this:

/usr/local/bin/node           # latest (default, linked to LTS in this case)
/usr/local/bin/node-v9.x.x    # latest 9.x
/usr/local/bin/node-v8.x.x    # latest LTS (ATM)

/usr/local/bin/npm            # NPM shipped with v8.x.x
/usr/local/bin/npm-v9.x.x     # NPM shipped with NodeJS 9.x
/usr/local/bin/npm-v8.x.x     # NPM shipped with NodeJS LTS

It is also possible to remove a single version like this:

class { '::nodejs':
  # ...
  instances_to_remove => ['9.x.x'],
}

Please keep in mind that instances_to_remove doesn't remove version specifier like lts or latest.

Setup using custom amount of cpu cores

By default, all available cpu (that are detected using the ::processorcount fact) cores are being used to compile nodejs. Set cpu_cores to any number of cores you want to use. This is mainly intended for the use with make_install => true for parallelisation purposes.

class { 'nodejs':
  version      => 'lts',
  cpu_cores    => 2,
  make_install => true,
}

Configuring $NODE_PATH

The environment variable $NODE_PATH can be configured using the init manifest:

class { '::nodejs':
  version   => 'lts',
  node_path => '/your/custom/node/path',
}

It is not possible to adjust a $NODE_PATH through ::nodejs::install.

Binary path

node and npm are linked to /usr/local/bin to be available in your system $PATH by default. To link those binaries to a different directory such as /bin, the parameter target_dir can be modified accordingly:

class { 'nodejs':
  version    => 'lts',
  target_dir => '/bin',
}

NPM Provider

NPM packages can be installed just like any else package using Puppet's package type, but with a special provider, namely npm:

package { 'express':
  provider => npm
}

Note: When deploying a new machine without nodejs already installed, your npm package definition requires the nodejs class:

class { 'nodejs':
  version => 'lts'
}

package { 'express':
  provider => 'npm',
  require  => Class['nodejs']
}

NPM installer (deprecated)

Note: this API is deprecated and will be removed in 3.0. It's recommended to either package your applications properly using npm and install them as package using the npm provider or to directly run npm install when deploying your application (e.g. with a custom Puppet module).

This module is focused on setting up an environment with nodejs, application deployment should be handled in its own module. In the end this was just a wrapper on top of npm which runs an exec with npm install and a configurable user and lacks proper ensure => absent support.

The nodejs installer can be used if a npm package should not be installed globally, but in a certain directory.

There are two approaches how to use this feature:

Installing a single package into a directory

::nodejs::npm { 'npm-webpack':
  ensure    => present, # absent would uninstall this package
  pkg_name  => 'webpack',
  version   => 'x.x',               # optional
  options   => '-x -y -z',          # CLI options passed to the "npm install" cmd, optional
  exec_user => 'vagrant',           # exec user, optional
  directory => '/target/directory', # target directory
  home_dir  => '/home/vagrant',     # home directory of the user which runs the installation (vagrant in this case)
}

This would install the package webpack into /target/directory with version x.x.

Executing a package.json file

::nodejs::npm { 'npm-install-dir':
  list      => true,       # flag to tell puppet to execute the package.json file
  directory => '/target',
  exec_user => 'vagrant',
  options   => '-x -y -z',
}

Proxy

When your puppet agent is behind a web proxy, export the http_proxy environment variable:

export http_proxy=http://myHttpProxy:8888

Skipping package setup

As discussed in willdurand/composer#44 each module should get a build_deps parameter which can be used in edge cases in order to turn the package setup of this module off:

class { '::nodejs':
  build_deps => false,
}

In this case you'll need to take care of the following packages:

  • tar
  • wget
  • make (if make_install = true)
  • gcc compiler (if make_install = true)

Hacking

The easiest way to get started is using bundler:

bundle install
bundle exec rake test
PUPPET_INSTALL_TYPE=agent BEAKER_setfile=spec/acceptance/nodesets/ubuntu-1804-x64.yml bundle exec rake acceptance

Note: to run the acceptance tests that are part of rake's test target, Docker is required.

Authors

Support

There are currently two main branches available, namely the 1.9 branch and 2.x. The support lifecycle is planned like this:

  • There's currently no plan to completely drop 1.9. If there's demand for simple bugfixes or security-related problems, patches will be accepted and released, however there won't be any active feature development.

  • Each release of 2.x is supported until the next after the next release is published. So e.g. 2.0 is supported until 2.2 is published. Each release has its own branch where bugfixes can be backported, on master the next minor or major release is developed.

  • There's currently no plan for a next major release.

License

puppet-nodejs is released under the MIT License. See the bundled LICENSE file for details.

puppet-nodejs's People

Contributors

amarcadet avatar beyerz avatar borisguery avatar chriserik avatar colinmutter avatar estliberitas avatar gpkfr avatar grafjo avatar jeff1evesque avatar jjtorroglosa avatar jwatroba avatar ke1del avatar leberknecht avatar ma27 avatar maneeshmp avatar marchev avatar marianschmotzer avatar martinseener avatar michaelbeil avatar rainopik avatar rgardler-msft avatar rv-jlombardo avatar sigmike avatar sray avatar studiomax avatar willdurand avatar ze12augusto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

puppet-nodejs's Issues

Add support for npm version

Hello,

currently only the shipped version of npm is available after package installation. If one updates npm with npm install -g npm and afterwards decides to use puppet to choose another version of nodejs: the updated npm will be overruled.

Is it possible (/or a pull request appriciated) to choose a specific npm version?

Duplicate declaration: Package[curl]

Getting a duplicate declaration error.

Duplicate declaration: Package[curl] is already declared in file /etc/puppet/modules/rbenv/manifests/dependencies/ubuntu.pp at line 16 at /etc/puppet/modules/nodejs/manifests/install.pp:59 on node precise64

Steps to reproduce:

  1. Use both alup/rbenv and nodejs modules.

Can't find npm command

I provisioned a new box today, where puppet-nodejs was having trouble installing the global npm packages I like. For each one, it said the npm command could not be found.

I wonder if puppet was trying to install my npm-provided packages before installing nodejs?

I was able to workaround this issue by manually requiring nodejs before my packages:

class { 'nodejs':
  version => 'stable'
}

package { [
  'coffee-script',
  'coffeelint',
  'csslint',
  'grunt-cli',
  'jshint',
  'less',
  'mocha',
  'sass',
  'stylus',
  ]:
  provider => 'npm',
  require => Class['nodejs']
}

I am missing a link to /usr/local/bin/node

i have a link to /usr/local/bin/node-v0.10.25 from /usr/local/node/node-v0.10.25/bin/node
But now i cant just use "node" in further recipes and don't know how to create that as i need the version number that is only available in the module...

Did i miss something?

Node js not Installed

I runned vagrant provision without errors but when i access to the vm i get this error:

-bash: /etc/profile.d/nodejs.sh: line 10: syntax error: unexpected end of file
vagrant@test:~$ node -v

This is the content of the defult.pp file.

class { 'nodejs':
  version    => 'stable',
  target_dir => '/bin',
}
03:34:48 {master} /d/Workspace/vagrant-enviroments/test$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

Here is what i get when i access the vm:

 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Tue Apr  8 15:33:57 2014 from 10.0.2.2
: command not found
-bash: /etc/profile.d/nodejs.sh: line 10: syntax error: unexpected end of file
vagrant@test:~$ node -v
The program 'node' can be found in the following packages:
 * node
 * nodejs
Try: sudo apt-get install <selected package>
vagrant@test:~$

`node` not in path

class { 'nodejs':
  version      => 'v0.10.29',
  make_install => false,
}

package { 'foo':
  provider => npm,
  ensure   => installed,
  require  => [Class['nodejs']],
}

exec { 'run foo':
  command => '/usr/local/node/node-default/bin/foo',
  require => [Package['zelda']],
}

I get the following error:

... change from notrun to 0 failed: /usr/bin/env: node: No such file or directory

I also don't see npm or node in /usr/local/bin but instead there's a weird link in there

$ ls -la /usr/local/bin/
drwxr-xr-x  2 root root 4096 Jun 29 19:52 .
drwxr-xr-x 11 root root 4096 Jun 29 19:51 ..
lrwxrwxrwx  1 root root   38 Jun 29 19:52 node-v0.10.29 -> /usr/local/node/node-v0.10.29/bin/node

Any suggestions?

install fails with r10k

I'm not familiar enough with r10k code to know why this would fail.. but when running

r10k puppetfile install

this module fails with

[R10K::TaskRunner - ERROR] Task #R10K::Task::Module::Sync:0x7f62a3498e20 failed while running: Command puppet module --modulepath /vagrant/modules install --version=1.6.3 --ignore-dependencies willdurand/nodejs exited with 1: Error: No such file or directory - /vagrant/modules/nodejs/spec/fixtures/modules/nodejs

R10k works when from a .git repo:

mod 'nodejs',
    :git => 'git://github.com/willdurand/puppet-nodejs.git',
    :ref => 'v1.6.3'

However, I believe common practice for forge modules is to omit the 'v' in the version number, so the forge version and the git version match up.

Error with ensure_packages in install.pp

Hi,

I get the following error that stems from install.pp:156

Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list python' returned 1: Error: No matching Packages to list

I am using make_install => true and running on an amazon ami. I see that all my python packages seem to be named python2.7 instead of just python.

Is there a way to work around this and provide the proper dependency? I realize this may be more of a puppet question than an issue with this module, but I thought I'd start here.

Thanks

When nodejs.org is down puppet don't working

Hi, in this moment nodejs.org is down, if you can try to up you deploy and it's frezee when execute, on this file modules/nodejs/lib/facter/nodejs_latest_version.rb checks version and makes all project freeze.

Invalid symlink at /spec/fixtures/modules/nodejs

In the .tar.gz from puppet forge, there's a symlink /spec/fixtures/modules/nodejs -> /Users/william/projects/puppet-nodejs. When using a utility like Packer to upload all modules, this is throwing an error because it can't find the link.

Line endings in /etc/profile.d/nodejs.sh corrupted file

This might cancel the issue but I'm using this module with Vagrant on a Windows machine which caused the line endings to be set incorrectly and corrupted the file once the VM was deployed and I attempted to SSH into the machine. I've fixed my node.js.erb file manually.

Suggest adding something similar as puppetlabs-concat; a .gitattribute with the following:

*sh.erb eol=lf

excessively verbose scrollback

Full disclosure: this is a minor complaint, I have no intention of fixing it myself, and I am not terribly familiar with conventions of the Node.js ecosystem.

The scrollback during installation is incredibly verbose: I count 11,928 lines of content when I require nodejs at module version 1.8.5. I think the least useful scrollback is Exec[nodejs-unpack-v0.12.0].

Iโ€™m thinking a flag to change the log level would be useful. At the very least, I would want the unpack lines redirected to /dev/null.

Could not install NodeJS via puppet.

I could not install NodeJS via puppet.
Error message was "Could not retrieve fact='nodejs_stable_version'"
I would like your advice. Any help is deeply appreciated. Thank you.

Vagrant v1.6.5 for MS Windows
Oracle VM VirtualBox v4.3.20 for MS Windows
Vagrant runs behind a HTTP proxy. Windows environment as attached.

github_question
-------start Vagrantfile------------

-- mode: ruby --

vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.box = "puppetlabs/ubuntu-12.04-64-puppet"
config.vm.provision "shell", inline: "puppet module install puppetlabs-stdlib"
config.vm.provision "shell", inline: "puppet module install maestrodev-wget"
config.vm.provision "shell", inline: "puppet module install willdurand-nodejs"

config.vm.provision :puppet do |puppet|
puppet.manifests_path = "provision/manifests"
puppet.manifest_file = "default.pp"
puppet.module_path = "provision/modules"
end
end
-------end Vagrantfile---------------

Puppet's provision\manifests\default.pp starts with the line "include nodejs"

Here's my vagrant up output.
------start vagrant up----------------
D:\vagrant\bancadev>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'puppetlabs/ubuntu-12.04-64-puppet'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'puppetlabs/ubuntu-12.04-64-puppet' is up to date...
==> default: Setting the name of the VM: bancadev_default_1418267345449_15050
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring proxy for Apt...
==> default: Configuring proxy environment variables...
==> default: Mounting shared folders...
default: /vagrant => D:/vagrant/bancadev
default: /tmp/vagrant-puppet-3/manifests => D:/vagrant/bancadev/provision/manifests
default: /tmp/vagrant-puppet-3/modules-0 => D:/vagrant/bancadev/provision/modules
==> default: Running provisioner: shell...
default: Running: inline script
==> default: stdin: is not a tty
==> default: Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
==> default: (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1117:in issue_deprecation_warning') ==> default: Notice: Preparing to install into /etc/puppet/modules ... ==> default: Notice: Downloading from https://forgeapi.puppetlabs.com ... ==> default: Notice: Installing -- do not interrupt ... ==> default: /etc/puppet/modules ==> default: ????????? puppetlabs-stdlib (v4.4.0) ==> default: Running provisioner: shell... default: Running: inline script ==> default: stdin: is not a tty ==> default: Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations ==> default: (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1117:inissue_deprecation_warning')
==> default: Notice: Preparing to install into /etc/puppet/modules ...
==> default: Notice: Downloading from https://forgeapi.puppetlabs.com ...
==> default: Notice: Installing -- do not interrupt ...
==> default: /etc/puppet/modules
==> default: ????????? maestrodev-wget (v1.5.6)
==> default: Running provisioner: shell...
default: Running: inline script
==> default: stdin: is not a tty
==> default: Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
==> default: (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1117:in issue_deprecation_warning') ==> default: Notice: Preparing to install into /etc/puppet/modules ... ==> default: Notice: Downloading from https://forgeapi.puppetlabs.com ... ==> default: Notice: Installing -- do not interrupt ... ==> default: /etc/puppet/modules ==> default: ????????? willdurand-nodejs (v1.8.4) ==> default: ????????? maestrodev-wget (v1.5.6) ==> default: ????????? puppetlabs-stdlib (v4.4.0) ==> default: Running provisioner: puppet... ==> default: Running Puppet with default.pp... ==> default: stdin: is not a tty ==> default: Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations ==> default: (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1117:inissue_deprecation_warning')
==> default: Could not retrieve fact='nodejs_stable_version', resolution='': Connection timed out - connect(2)
==> default: Could not retrieve fact='nodejs_latest_version', resolution='': Connection timed out - connect(2)
==> default: Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
==> default: Error: Invalid version string ''! at /etc/puppet/modules/nodejs/manifests/install.pp:183 on node localhost.mathregit.group
==> default: Wrapped exception:
==> default: Invalid version string ''!
==> default: Error: Invalid version string ''! at /etc/puppet/modules/nodejs/manifests/install.pp:183 on node localhost.mathregit.group
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

D:\vagrant\bancadev>
------end vagrant up----------------

github_question

How to install package globally?

I would like to install coffee-script and grunt-cli globally. How can this be achieved using the syntax

package { "grunt-cli":
  provider => 'npm',
  require => Class['nodejs'] 
}

NPM executables not symlinked

Hello all,
When I do:

nodejs::install { 'v0.12.2':
                version => 'v0.12.2',
        }

Without master nodejs install with:

class { 'nodejs':
  version => 'stable',
}

on Ubuntu 14.04 the instal of node was OK and the symlink of /usr/local/bin in ok too:

node-v0.12.2 -> /usr/local/node/node-v0.12.2/bin/node*

But there is no npm-v0.12.2 in there ....
Is this expected or is it a bug...

npm not found on Ubuntu 14.04

Code:

class { 'nodejs':
  version => 'stable',
  with_npm => true,
  make_install => true,
}

package { ['express', 'body-parser', 'jade', 'pm2' ]:
  provider => npm,
require  => Class['nodejs']
}

Debug output:

Debug: Exec[wget-nodejs-download-v0.10.32](provider=posix): Executing check 'test -s /usr/local/node/node-v0.10.32.tar.gz'
Debug: Executing 'test -s /usr/local/node/node-v0.10.32.tar.gz'
Debug: Exec[nodejs-unpack-v0.10.32](provider=posix): Executing check 'test -f /usr/local/node/node-v0.10.32/bin/node'
Debug: Executing 'test -f /usr/local/node/node-v0.10.32/bin/node'
Debug: Exec[nodejs-make-install-v0.10.32](provider=posix): Executing check 'test -f /usr/local/node/node-v0.10.32/bin/node'
Debug: Executing 'test -f /usr/local/node/node-v0.10.32/bin/node'
Debug: Prefetching npm resources for package
Debug: Executing ' list --json --global'
Debug: Warning: npm list --json exited with code 1
Debug: Error: npm list --json command error source did not contain any PSON!
Debug: Executing ' list --json --global'
Debug: Warning: npm list --json exited with code 1
Debug: Error: npm list --json command error source did not contain any PSON!
Error: Command npm is missing
Error: /Stage[main]/Celp_de/Package[jade]/ensure: change from absent to present failed: Command npm is missing

Wget referencing to v0.10.25 even when specifying version

Hi @willdurand and thanks for you job.

I'm using latest puppet-nodejs version on a DigitalOcean VPS running Ubuntu 12.04.3 x64.

The problem is that even when referencing a different version, the stable 0.10.25 version is downloaded.

Take a look here:

Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/File[nodejs-install-dir]/ensure: created
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/File[/usr/local/node/node-v0.10.25]/ensure: created
Notice: /Stage[main]//Nodejs::Install[v0.10.20]/File[/usr/local/node/node-v0.10.20]/ensure: created
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Wget::Fetch[nodejs-download-v0.10.25]/Exec[wget-nodejs-download-v0.10.25]/returns: executed successfully
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-unpack-v0.10.25]/returns: executed successfully

Then, the process fails after a while, saying:

Error: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Package[semver]: Provider gem is not functional on this host
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/File[nodejs-symlink-bin-with-version-v0.10.25]: Dependency Package[semver] has failures: true
Warning: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/File[nodejs-symlink-bin-with-version-v0.10.25]: Skipping because of failed dependenciesNotice: /Stage[main]/Nodejs/File[/usr/local/node/node-default]: Dependency Package[semver] has failures: true

Notice: /Stage[main]/Nodejs/File[/etc/profile.d/nodejs.sh]: Dependency Package[semver] has failures: true
Notice: Finished catalog run in 677.50 seconds
Warning: /Stage[main]/Nodejs/File[/usr/local/node/node-default]: Skipping because of failed dependencies
Warning: /Stage[main]/Nodejs/File[/etc/profile.d/nodejs.sh]: Skipping because of failed dependencies

My puppet file is

include nodejs

nodejs::install { 'v0.10.20':
  version => 'v0.10.20',
  with_npm => false,
  make_install => false,
}

Same problem even when setting with_npm to true.

EACCESS errors

Hi guys I was just trying to install some packages using nodejs from willdurand and I noticed that on my vagrant box I cannot manually add a package without using sudo, It is my understanding that nodejs is preferably used without sudo (although I know this is different on more recent versions).

So I was wondering if there could be a feature request for installing nodejs without sudo privileges.

Why not require Package['wget'] in your class?

Hi,

I'm new in the Puppet ecosystem and I wanted to use your module but I can't figure out how to install wget and co before actually install nodejs.

If wget is required to download the tar.gz why not put the require in your class?
Otherwise what solutions do I have to make it work?

I have tried stuff like that, but got "can't convert nil into String" for the line that begins with "before":

package { 'wget':
  ensure => present,
  before => Class['nodejs'],
}

# ...

class { 'nodejs':
  version => 'v0.10.17',
}

Also I'm using your module with Vagrant.

Thank you,
Antoine

Incorrect require

Hi,
Your module is great, but latest version has small issue. Two resources file:$node_binary and file:$npm_binary in init.pp manifest has require => Nodejs::Install["node-${version}"] but resource is nodejs::install { "nodejs-${version}" ("node-${version}" vs "nodejs-${version}").

npm modules not on $PATH

I'm having issues getting npm modules to be placed on the $PATH. I'm using v1.6.3 with the fixes from #33 and #30 and it's still not working for me.

My script is as follows

# Tools setup
class nodetools {

  class { 'nodejs':
    version      => 'stable',
    make_install => false
  }

  file { "npmrc":
      path => "/home/vagrant/.npmrc",
      ensure => "present",
      owner => vagrant,
      group => vagrant,
      mode => 644,
      source => "puppet:///modules/nodetools/.npmrc",
  }

  package { 'karma':
    provider => 'npm',
    ensure => '0.12.x',
    require => Class["nodejs"]
  }

  package { 'karma-jasmine':
    provider => 'npm',
    ensure => '0.1.x',
    require => Class["nodejs"]
  }
}

node and npm are available on the PATH, however, karma isn't available. Looking at npm list -g I can see Karma installed into /usr/local/node/node-default/lib with the karma executable at /usr/local/node/node-default/lib/node_modules/karma/bin/karma

Why hasn't this been linked to the global node bin? Is there something else that I've not done? A simple work-around would be to add each module bin to the PATH, but that's not sustainable long-term

Automatically require nodejs

Would it be possible to have puppet-nodejs automatically, implicitly, require nodejs?

Other puppet modules do this. As a puppet user, I feel like puppet should be automating more, not requiring me to remember that X module requires Y package.

Bad symlink nodejs -> /Users/william/projects/puppet-nodejs

Related to #45 (closed, so I decided to create a new ticket)

While using a --target-dir flag on a vagrant box

vagrant@CodeBoxIde:/puppet-codeBox/manifests$ sudo puppet module install willdurand-nodejs --target-dir /puppet-codeBox/modules
Notice: Preparing to install into /puppet-codeBox/modules ...
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
Error: No such file or directory - /puppet-codeBox/modules/nodejs/spec/fixtures/modules/nodejs
Error: Try 'puppet help module install' for usage

And looking at the path causing the issue:

lrwxrwxrwx 1 vagrant vagrant   37 Oct 13 10:27 nodejs -> /Users/william/projects/puppet-nodejs

Node.js installation fails in 1.5.0

Hello,

since commit 0f9d457 this module does not work in our (Vagrant) setup anymore. We receive the following error message during provisioning:

Error: Could not find dependency Nodejs::Install[node-v0.8.23] for File[/usr/local/bin/node]

Reverting to v1.4.0 fixed the issue for us.

Kind regards,
ulrichsg

Install globals with non-root

I would like to install npm global packages with my vagrant user after provisioning. Currently, I add this to my puppet node:

  # Allow vagrant user to global install npm packages
  exec { 'chown node directory':
    command => '/bin/chown -R vagrant:vagrant /usr/local/node/',
    path    => '/bin',
    user    => 'root',
  }

Is there a better way to do this -- perhaps by telling the plugin to use a different npm prefix setting?

Deprecated gem option being used

I am also encountering this error:

err: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Package[semver]/ensure: change from absent to present failed: Execution of '/usr/local/rbenv/shims/gem install --include-dependencies --no-rdoc --no-ri semver' returned 1: ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: --include-dependencies

This option was deprecated in mid 2007. (Source: http://projects.puppetlabs.com/issues/19663)

Tries to compile node before installing g++

At least that's what I think is happening. I did look through the source code but it seems to specify that g++ should be present before compiling node - although I'm not an expert at Puppet so I don't know where to go from there.

This repo contains a Vagrant box that should reproduce the issue. I've put the output when running vagrant up in a gist. From L991 and below, it looks like it's running make before installing g++ (at L1000).

NPM fails to install when using make_install=>false

npm tries to install prior to nodejs

Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/File[nodejs-symlink-bin-with-version-v0.10.20]/ensure: created
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/File[nodejs-symlink-bin-v0.10.20]/ensure: created
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: npm cannot be installed without nodejs.
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: Install node first, and then try again.
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: 
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: Maybe node is installed, but not in the PATH?
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: Note that running as sudo can change envs.
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: 
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Error: sh install.sh returned 1 instead of one of [0]
Error: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[npm-install-v0.10.20]/returns: change from notrun to 0 failed: sh install.sh returned 1 instead of one of [0]
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/File[npm-symlink-v0.10.20]: Dependency Exec[npm-install-v0.10.20] has failures: true
Warning: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/File[npm-symlink-v0.10.20]: Skipping because of failed dependencies
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Wget::Fetch[nodejs-download-v0.10.20]/Exec[wget-nodejs-download-v0.10.20]/returns: executed successfully
Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-v0.10.20]/Exec[nodejs-unpack-v0.10.20]/returns: executed successfully

npm doesn't install with make_install => false

Here's the manifest:

class { 'nodejs':
  version => 'v0.10.18',
  make_install => false,
}

Node installs just fine, but npm doesn't.

There's an error in the log, it seems to occur because wget cannot download install.sh into /usr/local/node/install.sh. Indeed, when I run that command manually, it says it doesn't have permission; running it with sudo works.

Not sure why this happens, from wget module's source code, the command is run as root.

Error: Could not find class nodejs for ubuntu on node ubuntu

Steps to reproduce:

  1. puppet module install willdurand-nodejs
  2. Create file in nodejs/manifests/nodejs.pp:
include nodejs

nodejs::install { 'v0.10.13': 
    version => 'v0.10.13',
}
  1. puppet apply

Then I'm getting the aforementioned error:

Error: Could not find class nodejs for ubuntu on node ubuntu

Set NODE_PATH in nodejs.sh

Shouldn't this module set the NODE_PATH environment variable in the nodejs.sh file added to profile.d?

npm + packages aren't installed in default-target-dir

I'm trying to execute the following puppet code:

class { 'nodejs':
  version       => 'v0.10.0',
  make_install  => false,
  with_npm      => true,
}

package { 'less':
    ensure      => '1.6.1',
    provider    => 'npm',
    require     => Class["nodejs"],
}

and commands (node, npm, less) are installed in the default path: /usr/local/node/node-default/bin/ but not in the target directory by default: /usr/local/bin

How I can force the installation in target dir?

Additional info:
My real problem is that I need to execute an external script under sudo, and it hasn't access to NODEJS_HOME path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:

Error with tar --strip-components=1

==> default: Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-unpack-v0.12.0]/returns: tar: Unexpected EOF in archive
==> default: Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-unpack-v0.12.0]/returns: tar: Unexpected EOF in archive
==> default: Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-unpack-v0.12.0]/returns: tar: Error is not recoverable: exiting now
==> default: Error: tar -xzvf node-v0.12.0.tar.gz -C /usr/local/node/node-v0.12.0 --strip-components=1 returned 2 instead of one of [0]
==> default: Error: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-unpack-v0.12.0]/returns: change from notrun to 0 failed: tar -xzvf node-v0.12.0.tar.gz -C /usr/local/node/node-v0.12.0 --strip-components=1 returned 2 instead of one of [0]
==> default: Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-make-install-v0.12.0]: Dependency Exec[nodejs-unpack-v0.12.0] has failures: true
==> default: Warning: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/Exec[nodejs-make-install-v0.12.0]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/File[nodejs-symlink-bin-with-version-v0.12.0]: Dependency Exec[nodejs-unpack-v0.12.0] has failures: true
==> default: Warning: /Stage[main]/Nodejs/Nodejs::Install[nodejs-stable]/File[nodejs-symlink-bin-with-version-v0.12.0]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Nodejs/File[/usr/local/node/node-default]: Dependency Exec[nodejs-unpack-v0.12.0] has failures: true
==> default: Warning: /Stage[main]/Nodejs/File[/usr/local/node/node-default]: Skipping because of failed dependencies
==> default: Notice: /Stage[main]/Nodejs/File[/etc/profile.d/nodejs.sh]: Dependency Exec[nodejs-unpack-v0.12.0] has failures: true
==> default: Warning: /Stage[main]/Nodejs/File[/etc/profile.d/nodejs.sh]: Skipping because of failed dependencies
==> default: Notice: Finished catalog run in 21.80 seconds
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

This is inside of vagrant -- centos 6.5.

Use npm in local mode

How can we use npm provider to install packages in local mode (i.e. install passport package inside the app folder).

root group

I just lost a few days thinking I've been doing something wrong It was staring me in the face when i went through the source code a few times.

Could you please add a note to say that the user must be in the 'root' group for this module to work correctly or allow the user to specify the groups that own they key files generated by this module.

This isn't a requirement of any of the other modules that I've used from Puppetlabs. I was stumped as to why these two modules didn't work... now I see that they are both similar in this aspect!!

nodejs requires semver gem without ensuring that gem provider is functional

The module requires the semver gem, but doesn't ensure that the rubygems package is installed. This causes the module to break on some distributions (tested with debian and centos) if the gem binary is not otherwise installed (the base ruby packages needed by puppet do not install the gem binary automatically on these distributions).

Error: Cannot alias File[nodejs-symlink-bin-with-version-v0.10.19]

Hi,

I'm getting this error while trying to install nodejs on Ubuntu 13:
Error: Cannot alias File[nodejs-symlink-bin-with-version-v0.10.19] to ["/usr/local/node/node-v0.10.19"] at [project]/modules/nodejs/manifests/install.pp:151; resource ["File", "/usr/local/node/node-v0.10.19"] already declared at [project]/modules/nodejs/manifests/install.pp:119

I have this in the manifest file:
nodejs::install { 'v0.10.19':
version => 'v0.10.19',
make_install => true,
target_dir => '/usr/local/node',
}

Disable cache

It would be good to be able to disable the cache for the latest version and stable version so it won't create an error if nodejs.org is unavailable.

Does not create a symlink

When node is installed using:

class { 'nodejs':
    version => 'v0.10.33',
}

Then the binary is under /usr/local/bin/node-v0.10.33. Missing /usr/local/bin/node symlink.

This is under CentOS 7.

Cannot use behind a proxy

It doesn't pick up the proxy server set in the puppet config, so cannot find the latest and stable versions

Error on node-gyp rebuild while installing packages with npm

While installing packages that require a node-gyp rebuild (like zombie) the following error occurs:

Error: node-gyp requires that the user's home directory is specified in either of the environmental variables HOME or USERPROFILE

This is a fix for that (in puppet/provider/package/npm.rb) (borrowed from puppet labs-nodejs):

  if Puppet::Util::Package.versioncmp(Puppet.version, '3.0') >= 0
    has_command(:npm, 'npm') do
      is_optional
      environment :HOME => "/root"
    end
  else
    optional_commands :npm => 'npm'
  end

undefined method `require_relative' for main:Object

With 1.8.1 installed, I get the following error:

Notice: /File[/var/lib/puppet/lib/facter/nodejs_functions.rb]/ensure: defined content as '{md5}e572cc3963f2f3c2e34b0ad97ba9beae'
Error: Could not retrieve local facts: undefined method `require_relative' for main:Object
Error: Failed to apply catalog: Could not retrieve local facts: undefined method `require_relative' for main:Object

It seems to be caused by the facters in lib/

I've tested it with:
puppet 3.7.0/3.7.1
facter 2.2.0
ruby 1.8.7

Provider npm is not functional on this host

Using vagrant for a CentOS 6 VM. Here's the pertinent puppet config.

  nodejs::install { 'v0.10.20':
    version           => 'v0.10.20',
    make_install      => false,
    with_npm          => true,
  }

  package { 'grunt-cli':
    provider => 'npm',
  }
Notice: /Stage[main]/Build_nodejs/Package[nodejs]/ensure: created
Notice: /Stage[main]/Build_nodejs/Package[npm]/ensure: created
Error: /Stage[main]/Build_grunt/Package[grunt-cli]: Provider npm is not functional on this host

"package { 'grunt-cli'..." worked OK with puppetlabs/nodejs .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.