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

后端 未结 10 1637
眼角桃花
眼角桃花 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: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 . 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.
    
    

提交回复
热议问题