1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub ActionsでBuildしたら「error TS2688: Cannot find type definition file for '@testing-library/jest-dom'. error TS2688: Cannot find type definition file for 'jest'. error TS2688: Cannot find type definition file for 'node'.」と言われた

Posted at

はじめに

今回はGitHub ActionsでBuild時に起きたエラーについて書いていきます。

問題

エラーメッセージ
error TS2688: Cannot find type definition file for '@testing-library/jest-dom'.
 The file is in the program because:
  Entry point of type library '@testing-library/jest-dom' specified in compilerOptions

error TS2688: Cannot find type definition file for 'jest'.
 The file is in the program because:
  Entry point of type library 'jest' specified in compilerOptions

error TS2688: Cannot find type definition file for 'node'.
 The file is in the program because:
  Entry point of type library 'node' specified in compilerOptions
  
Error: Process completed with exit code 1.

スクリーンショット 2025-01-26 2.22.46.png

main.yml
  # ビルドジョブ - テスト完了後に実行
  build:
    name: Build
    needs: [test] # テストジョブが成功した後に実行
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: "npm"

      # プロジェクトのビルド
      - name: Build
        run: npm run build

      # ビルド成果物をアップロード
      - name: Upload build artifacts
        uses: actions/upload-artifact@v3
        with:
          name: build-files
          path: dist/ # ビルド出力ディレクトリ

解決方法

main.yml
  # ビルドジョブ - テスト完了後に実行
  build:
    name: Build
    needs: [test] # テストジョブが成功した後に実行
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: "npm"

      # 型定義のインストールを追加
+     - name: Install type definitions
+       run: npm install --save-dev @types/jest @types/node @types/testing-library__jest-dom

      # プロジェクトのビルド
      - name: Build
        run: npm run build

      # ビルド成果物をアップロード
      - name: Upload build artifacts
        uses: actions/upload-artifact@v3
        with:
          name: build-files
          path: dist/ # ビルド出力ディレクトリ

おわりに

Vite環境でTypeScriptを採用してのCI/CDは初めてで型定義のインストールが必要だと分かり、上記のコードを追加して解決できました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?