Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

npm ls "forgets" nested linked dependencies when run programmatically #8

@cressie176

Description

@cressie176

npm.commands.ls drops nested linked libraries when run programmatically. e.g.

module-a/package.json

{
    "name": "module-a",
    "dependencies": {
        "module-b" : "*",
    }
}

module-b/package.json

{
    "name": "module-b",
    "dependencies": {
        "module-c" : "*",
    }
}

module-c/package.json

{
    "name": "module-c",
}
npm.load({}, function() {
    npm.prefix = './work/module-a/';
    npm.commands.ls(undefined, true, function(err, full, lite) {
        console.log("Module A\n", lite);
        npm.prefix = './work/module-b'/;
        npm.commands.ls(undefined, true, function(err, full, lite) {
            console.log("Module B\n", lite);           
        });
    });
});

The output from the second 'ls' command does not list Module C as a dependency of Module B

The bug is in read_installed, and to do with the use of rpSeen. While traversing module-A's dependencies npm correctly detects that Module-B depends on Module-C, but after returning, this information is not present in the object stashed in rpSeen.

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