简体   繁体   中英

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

I can't find a way to fix this. It is working locally as usual. I have tried using path aliases, relative paths, updating the yaml file many times, but can't find it to work.

The gihub actions spits this 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.

this is my config

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"]
}

I have tried changing the github actions yaml config, switching from relative paths to path aliases, but can't make it work.

Delete node_modules folder and run "npm install". Hope this will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM