【问题标题】:Teams-cli using Github actions fails to find package.json使用 Github 操作的 Teams-cli 无法找到 package.json
【发布时间】:2022-01-08 21:11:49
【问题描述】:

使用以下脚本发布 Microsoft 团队应用:

steps:
  # Setup environment.
  - uses: actions/setup-node@v2
    with:
      node-version: '14'
  - run: npm install

  - name: Checkout the code
    uses: actions/checkout@v2

  - uses: OfficeDev/teamsfx-cli-action@v1
    with:
      commands: validate

  # Publish the Teams App.
  - uses: OfficeDev/teamsfx-cli-action@v1
    with:
      commands: publish

我收到以下验证和发布操作的查找包错误:

UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/node_modules/undefined/package.json'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at getVersionString (/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:61:28)
    at /home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:87:18
    at Generator.next (<anonymous>)
    at /home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:30:71
    at new Promise (<anonymous>)
    at __awaiter (/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:26:12)
    at /home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:68:8
    at Object.<anonymous> (/home/runner/work/ms-teams-tabs-app/ms-teams-tabs-app/node_modules/teamsfx-cli/lib/cli.js:89:4)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1721) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1721) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

通过控制台在本地运行命令或使用 Visual Code Teams 工具包都可以成功运行而没有问题,我看不到这里可能缺少什么。

【问题讨论】:

    标签: github-actions microsoft-teams teams-toolkit


    【解决方案1】:

    将脚本更新为以下内容以正确安装所需的软件包:

    steps:
      # Setup environment.
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
      - uses: pnpm/action-setup@v2.0.1
        with:
            version: 6.12.1
      - name: Checkout
        uses: actions/checkout@v2.3.1
        with:
          persist-credentials: false
      - name: Install and Build ?
        run: | # Install npm packages
          pnpm install
    
      - uses: OfficeDev/teamsfx-cli-action@v1
        with:
          commands: validate
    
      # Publish the Teams App.
      - uses: OfficeDev/teamsfx-cli-action@v1
        with:
          commands: publish
    

    【讨论】:

      【解决方案2】:

      @RichardMc 你自己解决了吗?

      我从第一个版本中看到的一个问题是,您应该在Checkout 之后运行npm install,而不是在它之前。

      其实你不用那么麻烦单独使用action,自己编写工作流文件。 Teams 应用程序开发存在 CI/CD 支持,通过脚本涵盖 GitHub、Azure DevOps、Jenkins 和其他平台的平台。 您只需复制 GitHub 的预定义 yml 文件并进行自定义以满足您自己的需求。

      详情请咨询https://aka.ms/teamsfx-cicd-insider-guide

      【讨论】:

        猜你喜欢
        • 2020-08-20
        • 2020-02-07
        • 2021-08-27
        • 2021-08-02
        • 2022-11-25
        • 1970-01-01
        • 2020-09-19
        • 2021-03-08
        • 2021-04-23
        相关资源
        最近更新 更多