如何列出npm用户安装的软件包?

本文翻译自:How to list npm user-installed packages?

How do I list the user-installed package ONLY in npm ? 如何仅在npm列出用户安装的软件包? When I do npm -g list it outputs every package and their dependencies, which is not what I want. 当我执行npm -g list它会输出每个包及其依赖项,这不是我想要的。


#1楼

参考:https://stackoom.com/question/1DGTw/如何列出npm用户安装的软件包


#2楼

One way might be to find the root directory of modules using: 一种方法可能是使用以下方法查找模块的根目录:

npm root
/Users/me/repos/my_project/node_modules

And then list that directory... 然后列出该目录......

ls /Users/me/repos/my_project/node_modules
grunt                   grunt-contrib-jshint

The user-installed packages in this case are grunt and grunt-contrib-jshint 在这种情况下,用户安装的包是grunt和grunt-contrib-jshint


#3楼

Node_modules contains user-installed packages so change the directory to node_modules and list the items. Node_modules包含用户安装的软件包,因此将目录更改为node_modules并列出项目。 Core Modules are defined in node's source in the lib/ folder. 核心模块lib/文件夹的节点源中定义。

Example:

     example@example:~/:~/node_modules$ ls
     express  maxmind-native  node-whois  socket.io  ua-parser-js
     geoip    mongoskin       pdfkit      tail       zeromq
     maxmind  nodemailer      request     ua-parser  zmq

#4楼

您可以使用以下命令获取所有全局安装模块的列表:

ls `npm root -g`


#5楼

This works pretty well too: npm list -g --depth=0 这也很好用: npm list -g --depth=0

  • npm : the Node package manager command line tool npm :Node包管理器命令行工具
  • list -g : display a tree of every package found in the user's folders (without the -g option it only shows the current directory's packages) list -g :显示在用户文件夹中找到的每个包的树(没有-g选项,它只显示当前目录的包)
  • depth 0 / — depth=0 : avoid including every package's dependencies in the tree view depth 0 / - depth = 0 :避免在树视图中包含每个包的依赖关系

#6楼

To see list of all packages that are installed. 查看已安装的所有软件包的列表。

$ npm ls --parseable | awk '{gsub(/\/.*\//,"",$1); print}'| sort -u

show parseable of npm packages list https://docs.npmjs.com/cli/ls#parseable 显示可解析的npm包列表https://docs.npmjs.com/cli/ls#parseable

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值