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

Upgraded NPM causes problems with npm install #247

Open
Brantone opened this issue Jun 8, 2022 · 1 comment
Open

Upgraded NPM causes problems with npm install #247

Brantone opened this issue Jun 8, 2022 · 1 comment

Comments

@Brantone
Copy link
Contributor

Brantone commented Jun 8, 2022

🗣️ 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

@Brantone
Copy link
Contributor Author

Brantone commented Jun 8, 2022

Possible options :

  • incorporate this PR: Compensate for NPM CLI deprecating -global #246
  • downgrade to NPM version (reports saying 7.x is fine, but lower 8.x < 8.11 might be ok as well)
  • force upgrade to ensure NPM > 8.12.1
    • This poses catch-22 if already on impacted version - no way to upgrade since getting the error

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

1 participant