You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: helpers.rb
    path of file: ./repos/dependabot-core/npm_and_yarn/lib/dependabot/npm_and_yarn
    
    the code of the file until where you have to start completion: # typed: true
# frozen_string_literal: true

module Dependabot
  module NpmAndYarn
    module Helpers
      YARN_PATH_NOT_FOUND =
        /^.*(?<error>The "yarn-path" option has been set \(in [^)]+\), but the specified location doesn't exist)/

      def self.npm_version_numeric(lockfile)
        lockfile_content = lockfile.content
        return 8 if JSON.parse(lockfile_content)["lockfileVersion"].to_i >= 2

        6
      rescue JSON::ParserError
        6
      end

      def self.yarn_version_numeric(yarn_lock)
        if yarn_berry?(yarn_lock)
          3
        else
          1
        end
      end

    
      def self.yarn_major_version
        retries = 0
        output = run_single_yarn_command("--version")
        Version.new(output).major
      rescue Dependabot::SharedHelpers::HelperSubprocessFailed => e
        # Should never happen, can probably be removed once this settles
        raise "Failed to replace ENV, not sure why" if T.must(retries).positive?

        message = e.message

        missing_env_var_regex = %r{Environment variable not found \((?:[^)]+)\) in #{Dir.pwd}/(?<path>\S+)}

        if message.match?(missing_env_var_regex)
          match = T.must(message.match(missing_env_var_regex))
          path = T.must(match.named_captures["path"])

          File.write(path, File.read(path).gsub(/\$\{[^}-]+\}/, ""))
          retries = T.must(retries) + 1

          retry
        end