voxpupuli / puppet-nodejs

Puppet module to install nodejs and global npm packages
https://forge.puppet.com/puppet/nodejs
Apache License 2.0
113 stars 248 forks source link

nodejs::npm::global_config_entry cannot work on a platform that puts npm into a different path #434

Closed igalic closed 3 years ago

igalic commented 3 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

  class { 'nodejs':
    nodejs_package_name => 'node12',
    npm_package_name    => 'npm-node12',
    npm_path            => '/usr/local/bin/npm'
  }

  nodejs::npm::global_config_entry { 'unsafe-perm':
    ensure => 'present',
    value  => 'true',
  }

What are you seeing

All of my nodejs::npm::global_config_entry are failing, because the code isn't made to run on anything the author didn't anticipate. but it comes down to two things:

define nodejs::npm::global_config_entry (
  Enum['present', 'absent'] $ensure = 'present',
  $config_setting                   = $title,
  $cmd_exe_path                     = $nodejs::cmd_exe_path,
  $npm_path                         = $nodejs::params::npm_path,
  $value                            = undef,
) {
  include nodejs

npm_path defaults to $nodejs::params::npm_path rather than $nodejs::npm_path, which is wrong. $nodejs::params::npm_path for FreeBSD is also set to /usr/bin/npm rather than /usr/local/bin/npm.

next, we have a hard-coded path of /usr/bin/test, which on FreeBSD is located in /bin/test.

Both of these seem… unnecessary. If the PATH is correct, we shouldn't have to hard-code path, unless they are extremely esoteric.