V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
xiaoguaiwu
V2EX  ›  分享创造

通过 Node.js 获取电脑安装的软件,支持 Windows 和 Mac 两个平台

  •  
  •   xiaoguaiwu · 328 天前 · 916 次点击
    这是一个创建于 328 天前的主题,其中的信息可能已经有所发展或是发生改变。

    地址:https://github.com/Xutaotaotao/get-installed-apps

    通过 Node.js 获取电脑安装的软件,支持 Windows 和 Mac 两个平台。

    👨‍💻 安装

    npm install get-installed-apps

    🔌 用法

    ES6 Module

    import {getInstalledApps} from 'get-installed-apps'
    
    getInstalledApps().then(apps => {
      console.log(apps)
    })
    

    CommonJS

    const {getInstalledApps} = require('get-installed-apps')
    getInstalledApps().then(apps => {
      console.log(apps)
    })
    

    如果你只想在 mac 平台上使用,可以这么做:

    import {getMacInstalledApps} from 'get-installed-apps'
    
    getMacInstalledApps().then(apps => {
      console.log(apps)
    })
    

    getMacInstalledApps 有一个可选参数 directory, 默认是'/Applications',你如果还需要获取其他目录的 app,可以自己设置。

    如果你只想在 windows 平台上使用,可以这么做:

    import {getWinInstalledApps} from 'get-installed-apps'
    
    getWinInstalledApps().then(apps => {
      console.log(apps)
    })
    
    Corybyte
        1
    Corybyte  
       328 天前
    Linux 平台捏
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1146 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:27 · PVG 07:27 · LAX 16:27 · JFK 19:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.