首页 > 解决方案 > 使用 GitHub Actions 运行 npm run build 时找不到依赖项

问题描述

我有反应项目并将其保存在 GitHub 上。我创建了一个手动触发的 GitHub Actions 工作流。当我运行工作流时,它在yarn run build.

以下是我的工作流程.yml

name: Build manually

on: workflow_dispatch

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: yarn
    - run: yarn run build --if-present

以下是我的 tsconfig.json 的一部分:

{
    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "moduleResolution": "node",
        "importHelpers": true,
        "jsx": "react",
        "esModuleInterop": true,
        "sourceMap": true,
        "baseUrl": "./",
        "strict": true,
        "paths": {
            "@/*": [
                "src/*"
            ],
            "@@/*": [
                "src/.umi/*"
            ]
        },
        "allowSyntheticDefaultImports": true
    }
}

以下是错误日志:

2021-09-23T02:58:33.7147255Z ##[group]Run yarn run build --if-present
2021-09-23T02:58:33.7147937Z [36;1myarn run build --if-present[0m
2021-09-23T02:58:33.7196066Z shell: /usr/bin/bash -e {0}
2021-09-23T02:58:33.7196485Z ##[endgroup]
2021-09-23T02:58:33.8919216Z yarn run v1.22.11
2021-09-23T02:58:33.9421123Z $ umi build --if-present
2021-09-23T02:58:36.4882505Z [info] [webpackbar] Compiling Webpack
2021-09-23T02:59:28.4647582Z Browserslist: caniuse-lite is outdated. Please run:
2021-09-23T02:59:28.4648982Z npx browserslist@latest --update-db
2021-09-23T02:59:28.4649394Z 
2021-09-23T02:59:28.4649887Z Why you should do it regularly:
2021-09-23T02:59:28.4651119Z https://github.com/browserslist/browserslist#browsers-data-updating
2021-09-23T02:59:56.5801719Z [success] [webpackbar] Webpack: Compiled with some errors in 1.33m
2021-09-23T02:59:56.6330014Z  ERROR  Failed to compile with 6 errors2:59:56 AM
2021-09-23T02:59:56.6330883Z 
2021-09-23T02:59:56.6404867Z null
2021-09-23T02:59:56.6405486Z This dependency was not found:
2021-09-23T02:59:56.6405846Z 
2021-09-23T02:59:56.6408441Z * @/components/FormItem/DictionarySelector in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/applicationAddEdit.tsx, ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/ScreenSearch/index.tsx and 4 others
2021-09-23T02:59:56.6410674Z 
2021-09-23T02:59:56.6412168Z To install it, you can run: npm install --save @/components/FormItem/DictionarySelector
2021-09-23T02:59:56.6412883Z Child
2021-09-23T02:59:56.6413230Z     
2021-09-23T02:59:56.6414247Z     ERROR in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/applicationAddEdit.tsx
2021-09-23T02:59:56.6416646Z     Module not found: Error: Can't resolve '@/components/FormItem/DictionarySelector' in '/home/runner/work/xxx/xxx/src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication'
2021-09-23T02:59:56.6418880Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/applicationAddEdit.tsx 12:0-74 350:40-58
2021-09-23T02:59:56.6420434Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/ListComponent/index.tsx
2021-09-23T02:59:56.6422083Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/applicationTable.tsx
2021-09-23T02:59:56.6423459Z      @ ./src/.umi-production/core/routes.ts
2021-09-23T02:59:56.6424245Z      @ ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6425025Z      @ multi ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6425476Z     
2021-09-23T02:59:56.6426449Z     ERROR in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/ScreenSearch/index.tsx
2021-09-23T02:59:56.6428851Z     Module not found: Error: Can't resolve '@/components/FormItem/DictionarySelector' in '/home/runner/work/xxx/xxx/src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/ScreenSearch'
2021-09-23T02:59:56.6431080Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/ScreenSearch/index.tsx 5:0-74 61:30-48
2021-09-23T02:59:56.6432724Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneApplication/applicationSearch.tsx
2021-09-23T02:59:56.6434057Z      @ ./src/.umi-production/core/routes.ts
2021-09-23T02:59:56.6434848Z      @ ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6435635Z      @ multi ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6436384Z     
2021-09-23T02:59:56.6445337Z     ERROR in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneWorkbench/component/ScreenSearch/index.tsx
2021-09-23T02:59:56.6448049Z     Module not found: Error: Can't resolve '@/components/FormItem/DictionarySelector' in '/home/runner/work/xxx/xxx/src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneWorkbench/component/ScreenSearch'
2021-09-23T02:59:56.6450823Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneWorkbench/component/ScreenSearch/index.tsx 5:0-74 64:30-48
2021-09-23T02:59:56.6452682Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneWorkbench/component/ListComponent/index.tsx
2021-09-23T02:59:56.6454496Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/halftoneWorkbench/halftoneWorkbenchTable.tsx
2021-09-23T02:59:56.6455787Z      @ ./src/.umi-production/core/routes.ts
2021-09-23T02:59:56.6456685Z      @ ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6457550Z      @ multi ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6458015Z     
2021-09-23T02:59:56.6458903Z     ERROR in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/otterMgmt/otterMgmtAddEdit.tsx
2021-09-23T02:59:56.6461410Z     Module not found: Error: Can't resolve '@/components/FormItem/DictionarySelector' in '/home/runner/work/xxx/xxx/src/pages/home/processEngineeringMgmt/halftoneMgmt/otterMgmt'
2021-09-23T02:59:56.6463595Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/otterMgmt/otterMgmtAddEdit.tsx 13:0-74 342:38-56 353:38-56
2021-09-23T02:59:56.6465371Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/otterMgmt/components/ListComponent/index.tsx
2021-09-23T02:59:56.6466770Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/otterMgmt/otterMgmtTable.tsx
2021-09-23T02:59:56.6468058Z      @ ./src/.umi-production/core/routes.ts
2021-09-23T02:59:56.6469064Z      @ ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6469846Z      @ multi ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6470295Z     
2021-09-23T02:59:56.6471278Z     ERROR in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/locationAddEdit.tsx
2021-09-23T02:59:56.6473846Z     Module not found: Error: Can't resolve '@/components/FormItem/DictionarySelector' in '/home/runner/work/xxx/xxx/src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt'
2021-09-23T02:59:56.6476000Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/locationAddEdit.tsx 11:0-74 281:38-56
2021-09-23T02:59:56.6477655Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/components/ListComponent/index.tsx
2021-09-23T02:59:56.6479279Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/locationTable.tsx
2021-09-23T02:59:56.6480484Z      @ ./src/.umi-production/core/routes.ts
2021-09-23T02:59:56.6481282Z      @ ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6482048Z      @ multi ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6482511Z     
2021-09-23T02:59:56.6483983Z     ERROR in ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/components/ScreenSearch/index.tsx
2021-09-23T02:59:56.6486586Z     Module not found: Error: Can't resolve '@/components/FormItem/DictionarySelector' in '/home/runner/work/xxx/xxx/src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/components/ScreenSearch'
2021-09-23T02:59:56.6489006Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/components/ScreenSearch/index.tsx 6:0-74 56:28-46
2021-09-23T02:59:56.6490670Z      @ ./src/pages/home/processEngineeringMgmt/halftoneMgmt/storageLocationMgmt/locationSearch.tsx
2021-09-23T02:59:56.6491931Z      @ ./src/.umi-production/core/routes.ts
2021-09-23T02:59:56.6492735Z      @ ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6493513Z      @ multi ./src/.umi-production/umi.ts
2021-09-23T02:59:56.6495151Z build failed
2021-09-23T02:59:56.6495631Z Error: build failed

标签: reactjsnpmgithub-actionsyarnpkg

解决方案


推荐阅读