How to list npm user-installed packages?

前端 未结 15 2280
后悔当初
后悔当初 2020-12-02 03:09

How do I list the user-installed package ONLY in npm? When I do npm -g list it outputs every package and their dependencies, which is not what I wa

15条回答
  •  猫巷女王i
    2020-12-02 03:54

    npm ls
    

    npm list is just an alias for npm ls

    For the extended info use

    npm la    
    npm ll
    

    You can always set --depth=0 at the end to get the first level deep.

    npm ls --depth=0
    

    You can check development and production packages.

    npm ls --only=dev
    npm ls --only=prod
    

    To show the info in json format

    npm ls --json=true
    

    The default is false

    npm ls --json=false
    

    You can insist on long format to show extended information.

    npm ls --long=true
    

    You can show parseable output instead of tree view.

    npm ls --parseable=true
    

    You can list packages in the global install prefix instead of in the current project.

    npm ls --global=true
    npm ls -g // shorthand
    

    Full documentation you can find here.

提交回复
热议问题