簡體   English   中英

錯誤 TS2307:找不到模塊或其對應的類型聲明。 在 Github 操作

[英]error TS2307: Cannot find module or its corresponding type declarations. on Github Actions

我找不到解決這個問題的方法。 它像往常一樣在本地工作。 我嘗試使用路徑別名、相對路徑,多次更新 yaml 文件,但無法找到它的工作方式。

gihub 動作吐出這個Run yarn build yarn run v1.22.19 warning package.json: No license field $ tsc Error: src/application/Feed/Activity/AddActivity.handler.ts(7,37): error TS2307: Cannot find module '@domain/Feed/Activity/Dto/Activity.response.dto' or its corresponding type declarations. Error: src/domain/Feed/Activity/Activity.mapper.ts(2,37): error TS2307: Cannot find module './Dto/Activity.response.dto' or its corresponding type declarations. Error: src/infrastructure/Serverless/Controller/Feed/Activity/AddActivity.controller.ts(4,37): error TS2307: Cannot find module '@domain/Feed/Activity/Dto/Activity.response.dto' or its corresponding type declarations. Error: src/infrastructure/Serverless/GetStream/Feed/Activity/Mapper/Activity.mapper.ts(6,37): error TS2307: Cannot find module '@domain/Feed/Activity/Dto/Activity.response.dto' or its corresponding type declarations. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Error: Process completed with exit code 2. Run yarn build yarn run v1.22.19 warning package.json: No license field $ tsc Error: src/application/Feed/Activity/AddActivity.handler.ts(7,37): error TS2307: Cannot find module '@domain/Feed/Activity/Dto/Activity.response.dto' or its corresponding type declarations. Error: src/domain/Feed/Activity/Activity.mapper.ts(2,37): error TS2307: Cannot find module './Dto/Activity.response.dto' or its corresponding type declarations. Error: src/infrastructure/Serverless/Controller/Feed/Activity/AddActivity.controller.ts(4,37): error TS2307: Cannot find module '@domain/Feed/Activity/Dto/Activity.response.dto' or its corresponding type declarations. Error: src/infrastructure/Serverless/GetStream/Feed/Activity/Mapper/Activity.mapper.ts(6,37): error TS2307: Cannot find module '@domain/Feed/Activity/Dto/Activity.response.dto' or its corresponding type declarations. error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Error: Process completed with exit code 2.

這是我的配置

name: APP_NAME
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  workflow_dispatch:
jobs:
  build_test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          persist-credentials: false
      - uses: actions/setup-node@v3
        with:
          node-version: lts/*
          cache: yarn
      - name: install
        run: yarn --immutable
      - name: build
        run: yarn build
      - name: Install B4A Cli
        run: curl https://raw.githubusercontent.com/back4app/parse-cli/back4app/installer.sh | /bin/bash
      - name: Configure B4A Cli and set it default
        run: echo $ACCOUNT_KEY | b4a configure accountkey && b4a default $APP_NAME
      - name: Deploy
        run: b4a deploy

Package.json

{
  "description": "",
  "main": "src/main.js",
  "scripts": {
    "lint": "eslint src/",
    "test": "jest",
    "build": "tsc",
    "dev:parse": "mongodb-runner start && parse-server --appId 'APP' --masterKey 'MASTER' --clientKey 'CLIENT' --databaseURI mongodb://localhost/test --cloud ./cloud/main.js",
    "debug:parse": "mongodb-runner start && parse-server --appId 'APP' --masterKey 'MASTER' --clientKey 'CLIENT' --databaseURI mongodb://localhost/test --cloud ./cloud/main.js --verbose",
    "dev:dash": "parse-dashboard --dev --appId APPLICATION_ID --masterKey MASTER_KEY --serverURL http://localhost:1337/parse --appName MY_APP"
  },
  "devDependencies": {
    "@types/jest": "^29.2.3",
    "@types/node": "^18.11.9",
    "@types/node-fetch": "^2.6.2",
    "@types/parse": "^3.0.1",
    "@types/uuid": "^8.3.4",
    "@typescript-eslint/eslint-plugin": "^5.42.1",
    "@typescript-eslint/parser": "^5.42.1",
    "eslint": "^8.27.0",
    "jest": "^29.3.1",
    "ts-jest": "^29.0.3",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.4"
  },
  "dependencies": {
    "class-transformer": "^0.5.1",
    "class-validator": "^0.13.2",
    "getstream": "^8.1.0",
    "module-alias": "^2.2.2",
    "parse-server": "^5.3.3",
    "reflect-metadata": "^0.1.13",
    "tsyringe": "^4.7.0",
    "uuid": "^9.0.0"
  },
  "_moduleAliases": {
    "@root": "cloud/",
    "@domain": "cloud/domain",
    "@application": "cloud/application",
    "@infrastructure": "cloud/infrastructure"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "lib": ["es6"],
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "ES2022",           
    "module": "commonjs",         
    "moduleResolution": "node",
    "rootDir": "src/",           
    "baseUrl": ".",           
    "paths": {
      "@root/*": ["./src/*"],
      "@domain/*": ["./src/domain/*"],
      "@application/*": ["./src/application/*"],
      "@infrastructure/*": ["./src/infrastructure/*"],
    },                          
    "outDir": "cloud",                       
    "removeComments": true,               
    "isolatedModules": true,              
    "allowSyntheticDefaultImports": true, 
    "esModuleInterop": false,                 
    "forceConsistentCasingInFileNames": true,
    "strict": true,                          
    "strictPropertyInitialization": false, 
    "alwaysStrict": true,                 
    "skipLibCheck": true                     
  },
  "include": ["src/"],
  "exclude": ["src/**/*.spec.ts", "cloud", "node_modules"]
}

我嘗試更改 github 操作 yaml 配置,從相對路徑切換到路徑別名,但無法使其工作。

刪除 node_modules 文件夾並運行“npm install”。 希望這會奏效

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM