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

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

    Unfortunately npm still doesn't have a way to view dependencies of non-installed packages. Not even a package's page list the dependencies correctly.

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

    To get it as a list:

    % npx npm-remote-ls --flatten dugite -d false -o false
    [
      'dugite@1.91.3',
      'checksum@0.1.1',
      'progress@2.0.3',
      'mkdirp@0.5.5',
      'rimraf@2.7.1',
      'tar@4.4.13',
      'optimist@0.3.7',
      'got@9.6.0',
      'minimist@1.2.5',
      'chownr@1.1.4',
      'glob@7.1.6',
      'fs-minipass@1.2.7',
      'minizlib@1.3.3',
      'minipass@2.9.0',
      'safe-buffer@5.2.1',
      'yallist@3.1.1',
      'wordwrap@0.0.3',
      '@szmarczak/http-timer@1.1.2',
      'cacheable-request@6.1.0',
      '@sindresorhus/is@0.14.0',
      'decompress-response@3.3.0',
      'duplexer3@0.1.4',
      'lowercase-keys@1.0.1',
      'mimic-response@1.0.1',
      'get-stream@4.1.0',
      'to-readable-stream@1.0.0',
      'p-cancelable@1.1.0',
      'url-parse-lax@3.0.0',
      'fs.realpath@1.0.0',
      'inflight@1.0.6',
      'inherits@2.0.4',
      'once@1.4.0',
      'path-is-absolute@1.0.1',
      'minimatch@3.0.4',
      'defer-to-connect@1.1.3',
      'clone-response@1.0.2',
      'get-stream@5.2.0',
      'http-cache-semantics@4.1.0',
      'lowercase-keys@2.0.0',
      'responselike@1.0.2',
      'keyv@3.1.0',
      'pump@3.0.0',
      'prepend-http@2.0.0',
      'normalize-url@4.5.0',
      'wrappy@1.0.2',
      'brace-expansion@1.1.11',
      'json-buffer@3.0.0',
      'end-of-stream@1.4.4',
      'concat-map@0.0.1',
      'balanced-match@1.0.0'
    ]
    
    0 讨论(0)
  • 2020-12-22 17:27

    You can use the npm-remote-ls module. You can install it globally:

    npm install -g npm-remote-ls
    

    And then call:

    npm-remote-ls bower
    

    Alternatively, npm@5.2.0 installed then you can use npx and avoid globally installing the command - just call:

    npx npm-remote-ls bower
    
    0 讨论(0)
  • 2020-12-22 17:27

    Here is the unpowerful official command:

    npm view <PACKAGE> dependencies
    

    It prints only the direct dependencies, not the whole tree.

    0 讨论(0)
提交回复
热议问题