How to view the dependency tree of a given npm module?

后端 未结 10 1526
眼角桃花
眼角桃花 2020-12-22 16:40

How can I get the tree of a module available to npm, but not installed locally ?

npm ll does the job for locally installed packages. But it doesn\'t wor

相关标签:
10条回答
  • 2020-12-22 17:04

    You can use howfat which also displays dependency statistics:

    npx howfat -r tree jasmine
    

    screensot

    0 讨论(0)
  • 2020-12-22 17:07

    There is also a nice web app to see the dependencies in a weighted map kind of view.

    For example:

    https://bundlephobia.com/result?p=sanitize-html@1.19.1

    0 讨论(0)
  • 2020-12-22 17:17

    This site allows you to view a packages tree as a node graph in 2D or 3D.

    http://npm.anvaka.com/#/view/2d/waterline

    Great work from @Avanka!

    0 讨论(0)
  • 2020-12-22 17:17

    If you want to get the actually dependency path of specific package and want to know why you have it, you can simply ask yarn why <MODULE>. example:

        $> yarn why mime-db
        yarn why v1.5.1
        [1/4] Why do we have the module "mime-db"...?
        [2/4] Initialising dependency graph...
        [3/4] Finding dependency...
        [4/4] Calculating file sizes...
        => Found "mime-db@1.37.0"
        info Reasons this module exists
           - "coveralls#request#mime-types" depends on it
           - Hoisted from "coveralls#request#mime-types#mime-db"
        info Disk size without dependencies: "196kB"
        info Disk size with unique dependencies: "196kB"
        info Disk size with transitive dependencies: "196kB"
        info Number of shared dependencies: 0
        Done in 0.65s.
    
    
    0 讨论(0)
  • 2020-12-22 17:18

    You can generate NPM dependency trees without the need of installing a dependency by using the command

    npm list
    

    This will generate a dependency tree for the project at the current directory and print it to the console.

    You can get the dependency tree of a specific dependency like so:

    npm list [dependency]
    

    You can also set the maximum depth level by doing

    npm list --depth=[depth]
    

    Note that you can only view the dependency tree of a dependency that you have installed either globally, or locally to the NPM project.

    0 讨论(0)
  • 2020-12-22 17:24

    View All the metadata about npm module

    npm view mongoose(module name)
    

    View All Dependencies of module

    npm view mongoose dependencies
    

    View All Version or Versions module

    npm view mongoose version
    npm view mongoose versions
    

    View All the keywords

    npm view mongoose keywords
    
    0 讨论(0)
提交回复
热议问题