最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get number of npm modules installed except dev dependencies - Stack Overflow

programmeradmin4浏览0评论

Is there an NPM CLI mand I can use to get the number of NPM Modules installed in my package, excluding those that are only Dev Dependencies? npm ls shows all of the packages, but it doesn't say how many or which are Dev Dependencies and which aren't. Thanks!

Is there an NPM CLI mand I can use to get the number of NPM Modules installed in my package, excluding those that are only Dev Dependencies? npm ls shows all of the packages, but it doesn't say how many or which are Dev Dependencies and which aren't. Thanks!

Share Improve this question asked May 17, 2018 at 18:36 Ben GublerBen Gubler 1,4414 gold badges20 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 13

Try this

  npm ls --only=prod --depth=0 | wc -l

Now subtract by 2 whatever you get. ( -1 is for last line and another -1 is for first line where npm ls shows the directory.)

(Use git-bash if you're using Windows.)

Demo

I got 14, it means I've 12 dependency.

You can use:

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

For this purpose, you can also do

npm ls --dev

or

npm ls --prod

Pipe it out to grep to count:

npm ls --depth=0 --dev | grep "\-\-" -c
发布评论

评论列表(0)

  1. 暂无评论