首页 > 解决方案 > 使用 execa 或 pkg-install run 'yarn install dependencies' 时如何输出安装日志

问题描述

我写了一个cli来初始化我的项目。下面是核心代码


import execa from 'execa'
import Listr from 'listr'
import { projectInstall } from 'pkg-install'
...
const tasks = new Listr([
    {
      title: `Initialize project ${options.projectPath}`,
      task: () => gitClone(options)
    },
    {
      title: 'Install dependencies',
      task: () =>
        projectInstall({
          prefer: 'yarn',
          cwd: options.targetDirectory
        })
    }
  ])

但是在终端看不到yarn install log。只能看到任务标题,等了几分钟,怎么才能正常输出yarn install log的进度条

在此处输入图像描述

标签: node.jscommand-line-interfaceyarnpkg

解决方案


推荐阅读