reactjs ESlint在GitHub Actions中找不到eslint包,但可以在本地工作,(莫诺雷波)

xuo3flqw  于 2023-06-29  发布在  React
关注(0)|答案(1)|浏览(123)

我第一次使用npm workspace来练习使用monorepo结构。然而,现在GitHub Actions给了我下面的错误。

Run npm run lint

> project@ lint /home/runner/work/project/project
> eslint . --fix --ext .js,.jsx

sh: 1: eslint: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! deis-course-evaluation@ lint: `eslint . --fix --ext .js,.jsx`
npm ERR! spawn ENOENT

项目结构

- backend
  - package.json
- frontend
  - package.json
- node_modules
- package.json
- .eslintrc.json

ci yml文件

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install dependencies
      run: npm install
    - name: Check for bugs and stylistic issues. 
      run: npm run lint

根package.json文件

{
    "name": "project",
    "private": true,
    "workspaces": [
        "backend",
        "frontend"
    ],
    "scripts": {
        "backend": "cd backend; nodemon ./index.js;",
        "frontend": "cd frontend; npm run dev",
        "doc": "jsdoc -c jsdoc.json",
        "lint": "eslint . --fix --ext .js,.jsx",
        "start": "npm run backend && npm run frontend"
    }
}

我已经尝试在工作流中安装eslint,但它给了我这个错误。

ESLint: 8.43.0

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/home/runner/work/project-name/project-name".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in ".eslintrc.json".

在工作流中安装插件也没有帮助。
我已经尝试在本地重新安装node_modules,虽然node_modules中存在@eslinteslint-plugin-react-hooks,但仍然没有解决ci期间的问题。
这似乎是eslint本身的问题,但我想知道是否有任何解决方法?

vs91vp4v

vs91vp4v1#

您的项目有哪些依赖项?
似乎依赖项丢失,因此不会安装。

相关问题