javascript - 找不到用于 CircleCI 构建的 ESLint

标签 javascript node.js circleci

我正在尝试在 CircleCI 上为 Node.js 应用程序运行一个简单的构建:

配置.yml

version: 2.0
jobs:
  build:
    working_directory: ~/app
    docker:
      - image: gcr.io/google-appengine/nodejs
    steps:
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install dependencies
          command: yarn
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
              - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: ESLint
          command: yarn lint

包.json
...
"scripts": { 
  "lint": "./node_modules/eslint/bin/eslint.js . --ext .js --fix",
}
...

我得到的错误是:
#!/bin/bash -eo pipefail
yarn lint
yarn run v1.16.0
$ ./node_modules/eslint/bin/eslint.js . --ext .js --fix
/bin/sh: 1: ./node_modules/eslint/bin/eslint.js: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 127

为什么 CircleCI 看不到 ESLint来自 node_modules ?
yarn lint命令在本地工作正常。

最佳答案

像这样,我可以工作

checklint:
        executor: docker-image
        steps:
            - checkout
            - node/install-packages:
                cache-path: ~/project/node_modules
                override-ci-command: npm install
            - run:
                command: npm run lint    

关于javascript - 找不到用于 CircleCI 构建的 ESLint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56493317/

相关文章:

javascript - 客户端应该使用http post还是socket.io将文件上传到我的nodejs服务器?

node.js - Heroku 连接 MONGODB 图集

javascript - 将 setTimeOut 属性添加到 div

javascript - PHP的json_encode在JS解析时有时会丢失最后一个 '}'括号

node.js - 在 Sublime Text 2 中重新启动/停止 nodejs 服务器?

python - Circleci 与 gcloud sdk UnicodeDecodeError

ruby-on-rails - 如何在 CircleCI 上指定较新版本的 wkhtmltopdf?

android - 如何在 Android 应用或 lib 项目的 circleci 上设置 NDK?

Javascript 获取元素 CSS 过渡阶段

javascript - 无法在 CKEditor 上编辑链接