Skip to content

Upgraded NPM causes problems with npm installΒ #247

Open
@Brantone

Description

@Brantone

πŸ—£οΈ Foreword

This is related to #245 , but adding bug Issue for visibility for others who might encounter it.

πŸ‘» Brief Description

With a recent version of NPM and it's push for deprecating -global, unfortunately it can cause problems when installing packages, because the warning still spits out, thus causing problems with expected JSON, this manifests in a client run with:

    * execute[install NPM package appcenter-cli] action run[2022-06-08T01:41:48-05:00] ERROR: nodejs::library::nodejs_helper::npm_list exception 785: unexpected token at ''

      
      ================================================================================
      Error executing action `run` on resource 'execute[install NPM package appcenter-cli]'
      ================================================================================
      
      NoMethodError
      -------------
      undefined method `[]' for false:FalseClass
      
      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/nodejs/libraries/nodejs_helper.rb:53:in `npm_package_installed?'
      /var/chef/cache/cookbooks/nodejs/resources/npm_package.rb:84:in `package_installed?'
      /var/chef/cache/cookbooks/nodejs/resources/npm_package.rb:54:in `block (3 levels) in class_from_file'
      
      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/nodejs/resources/npm_package.rb
      
       47:   execute "install NPM package #{new_resource.package}" do
       48:     cwd new_resource.path
       49:     command "npm install #{npm_options}"
       50:     user new_resource.user
       51:     group new_resource.group
       52:     environment npm_env_vars
       53:     live_stream new_resource.live_stream
       54:     not_if { package_installed? && no_auto_update? }
       55:   end
       56: end
      
      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/nodejs/resources/npm_package.rb:47:in `block in class_from_file'
      
      execute("install NPM package appcenter-cli") do
        action [:run]
        default_guard_interpreter :execute
        command "npm install  -global appcenter-cli@2.10.10"
        backup 5
        environment {"HOME"=>"/var/root", "USER"=>"root"}
        returns 0
        user "root"
        declared_type :execute
        cookbook_name "nodejs"
        domain nil
        not_if { #code block }
      end

There's a couple red-herrings in there, but believe I've tracked it down to https://github.com/sous-chefs/nodejs/blob/main/libraries/nodejs_helper.rb#L25

πŸ₯ž Cookbook version

Likely 7.3.0 and up

πŸ‘©β€πŸ³ Chef-Infra Version

N/A

🎩 Platform details

Definitely impacts macOS

Steps To Reproduce

Have NPM 8.11 installed (supposedly that's the affected version)

πŸš“ Expected behavior

Successful install

βž• Additional context

NPM : npm/cli#4980

There was a revert back to 8.12.1, but damage may already be done.

https://github.com/npm/cli/releases/tag/v8.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions