Skip to content

[BUG] npm.load does not accept any options. Only callback #2137

@slonkazoid

Description

@slonkazoid

Current Behavior:

npm.load does not accept any options. Only callback.

Expected Behavior:

npm.load actually recognizing my specified options and using them.

Steps To Reproduce:

steps to reproduce the behavior:

  1. In this environment...
  2. With the provided config...
  3. Run
const npm = require("npm");
npm.load({ loglevel: "silent" }, () => {
    console.log("npm loaded");
});
// TypeError: must call as: npm.load(callback)
  1. See error...

Environment:

  • OS: Linux Mint 20 Ulyana
  • Node: v14.15.0
  • npm: 6.4.12

What the .d.ts has to say about it:

    export interface Static extends NodeJS.EventEmitter {
        config: Config;
        commands: Commands;
        rollbacks: any[];
        spinner: Spinner;
        fullList: string[];
        abbrevs: Dictionary<string>;

        prefix: string;
        bin: string;
        globalBin: string;
        dir: string;
        globalDir: string;
        root: string;
        cache: string;
        tmp: string;


        load(cli: ConfigOptions): void; // Throws error
        load(callback: SimpleCallback<Config>): void; // Works
        load(cli: ConfigOptions, callback: SimpleCallback<Config>): void; // Throws error

        deref(command: string): string;
    }

Temporary Workaround

Note that with this workaround you can't install multiple modules in one line

const { exec } = require("child_process");
exec("npm <command> <options>");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 6.xwork is associated with a specific npm 6 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions