Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with nodejs repo and npm package conflict #452

Open
AxisNL opened this issue Nov 24, 2021 · 2 comments
Open

Issue with nodejs repo and npm package conflict #452

AxisNL opened this issue Nov 24, 2021 · 2 comments

Comments

@AxisNL
Copy link

AxisNL commented Nov 24, 2021

I'm pulling my hair out on issues with npm and nodejs on my Ubuntu 20.04.03 LTS machines..

If I run:

  class { 'nodejs':
    manage_package_repo => true,
  }

The nodesource repo will be added (which is fine), then the nodejs package will be installed (which is fine). The nodesource nodejs package provides npm. Perfect!

At this point, dpkg -l will show the nodejs package being installed, and the npm package isn't installed.

But, after this, puppet will remove the npm package, since the default setting for npm_package_ensure is absent. This somehow removes the nodejs package (not fine). No idea how this works, since according to apt the npm package isnt installed. But puppet says:

Notice: /Stage[main]/Nodejs::Install/Package[npm]/ensure: removed (corrective)

And /usr/bin/npm is gone, as is the nodejs package.

If I do:

  class { 'nodejs':
    manage_package_repo => true,
    npm_package_ensure => true
  }

Then that will fail. Nodejs will be installed from the nodesource repo, but the npm package only exists in the Ubuntu repo's, and that cannot be installed because it conflicts with the nodesource nodejs package.

So I'm in kind of a loop here!

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.12.1
  • Ruby: ?
  • Distribution: Ubuntu 20.04
  • Module version: 9.0.1
@kenyon
Copy link
Member

kenyon commented Nov 24, 2021

IMO it's best to avoid non-distribution package repos if possible. I use this module like this on Debian:

class { 'nodejs':
  manage_package_repo => false,
  npm_package_ensure  => present,
}

@cruelsmith
Copy link

cruelsmith commented Jul 4, 2023

Issue still exist and the reason is puppet itself. Found via debug run (CentOS 8 Stream system):

Debug: Executing: '/bin/rpm -q npm --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing: '/bin/rpm -q npm --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n --whatprovides'
Notice: /Stage[main]/Nodejs::Install/Package[npm]/ensure: current_value '2:16.20.1-1nodesource', should be 'absent' (noop) (corrective)

So the problem is that package also checks for whatprovides and because of that removed the nodejs package again. Properly the same issue on Debian / Ubuntu and other OSs. Only happens with the nodesource packages since npm in bundled in the nodejs package from them.


Current workaround would be to use nodejs::npm_package_name: false to ensure that Package[npm] is not manged at all and hope that other dependencies do not break. See

if $nodejs::npm_package_name and $nodejs::npm_package_name != false {
package { $nodejs::npm_package_name:
ensure => $nodejs::npm_package_ensure,
tag => 'nodesource_repo',
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants