voxpupuli / puppet-nodejs

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

Installing Angular-CLI happens on every run #314

Closed lverns closed 6 years ago

lverns commented 7 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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

On the server, I have the following class:

class npm_packages {

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

  package { 'typescript':
    ensure => 'present',
    provider => 'npm'
  }

  package { '@angular/cli@1.0.0':
    ensure => 'present',
    provider => 'npm'
  }
}

What are you seeing

ng seems to be properly installed, but every time I run the client, I see the following entry in the log:

Notice: /Stage[main]/Npm_packages/Package[@angular/cli@1.0.0]/ensure: created

What behaviour did you expect instead

I would expect to only see this entry the first time the client runs.

ekohl commented 7 years ago

I'm not that familiar with npm but I suspect this is something in puppet itself since you use the package resource. Could it be that it should be angular/cli@1.0.0 and the leading @ is tripping it up?

lverns commented 7 years ago

I took the @ off and while puppet still claims to run correctly, ng is not made accessible on the PATH. (Note that the first @ is part of the package name.)

I now see this on every run:

Notice: /Stage[main]/Npm_packages/Package[typescript]/ensure: created
Notice: /Stage[main]/Npm_packages/Package[angular/cli@1.0.0]/ensure: created

Re-adding the @ changes the output to

Notice: /Stage[main]/Npm_packages/Package[typescript]/ensure: created
Notice: /Stage[main]/Npm_packages/Package[@angular/cli@1.0.0]/ensure: created

but still doesn't properly install Angular CLI.

So the package is only properly installed on clients that were first run with the @ present, and I looks like I'll have to do some manual manipulation to get the other test boxes back into a good state.

matheo commented 7 years ago

I enabled the debug and it effectively runs

==> default: Notice: /Stage[main]/Main/Package[webpack-dev-server]/ensure: created
==> default: Debug: /Package[webpack-dev-server]: The container Class[Main] will propagate my refresh event
==> default: Debug: Executing: '/usr/bin/npm list --json --global'
==> default: Debug: Executing: '/usr/bin/npm install --global @angular/cli'

but it hangs, no idea if it's because the dependencies are many, but it doesn't make sense because from a Vagrant instance without it, I was able to run it and it doesn't take that much.

ekohl commented 7 years ago

I wonder what /usr/bin/npm list --json --global shows. Does it include @angular/cli?

matheo commented 7 years ago

I've moved @angular/cli installation to a command execution and after 5 mins I get a timeout, not just infinitely stuck:

==> default: Debug: Exec[Install Angular CLI](provider=posix): Executing '/usr/bin/npm install --global @angular/cli'
==> default: Debug: Executing: '/usr/bin/npm install --global @angular/cli'
==> default: Error: Command exceeded timeout
==> default: Error: /Stage[main]/Main/Exec[Install Angular CLI]/returns: change from notrun to 0 failed: Command exceeded timeout

Then executing:

/usr/bin/npm list --global --depth=0

it's indeed installed, so it's a problem with the return status?

/usr/lib
├── @angular/cli@1.4.2
ekohl commented 7 years ago

My expertise is puppet, not nodejs. This feels like an issue with nodejs/npm itself so I'm afraid I can't be of any help.

juniorsysadmin commented 6 years ago

There has been no recent correspondence on this, closing.