title: Why does 'vue-cli-service build' fail after creating a new eslint-plugin, with error 'TypeError: eslint.CLIEngine is not a constructor'?
body: <p>After creating a new eslint-plugin for a custom rule, <code>vue-cli-service build</code> fails (<code>eslint</code> works as expected, when triggered by <code>./node_modules/.bin/eslint --ext .js,.vue,.json ./ --max-warnings=0</code>).</p>
  
  <p><a href="https://github.com/aTegart/yarn-vue-eslint" rel="noreferrer"><strong>GitHub repository reproducing issue</strong></a></p>
  
  <p>Starting in an environment with a working <code>vue-cli-service build</code>, following the simplified instructions at <a href="https://blog.webiny.com/create-custom-eslint-rules-in-2-minutes-e3d41cb6a9a0" rel="noreferrer">https://blog.webiny.com/create-custom-eslint-rules-in-2-minutes-e3d41cb6a9a0</a>, also reproduces the issue. Running <code>vue-cli-service build</code> after every step, it starts failing after step 4: <code>yarn add --dev file:./eslint</code>, and the build still fails after all the steps are completed.</p>
  
  <p>Error message:</p>
  
  <pre><code>ERROR  Failed to compile with 32 errors      
  
  Module build failed (from ./node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js):
  TypeError: eslint.CLIEngine is not a constructor
     at Object.module.exports (MYPATH/node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js:223:27)
  
  ***repeats 31 more times***
  
  You may use special comments to disable some warnings.
  Use // eslint-disable-next-line to ignore the next line.
  Use /* eslint-disable */ to ignore all warnings in a file.
  ERROR  Build failed with errors.
  error Command failed with exit code 1.
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  </code></pre>
  
  <p><code>vue-cli-service build</code> stills fails after running <code>yarn install</code>, which says it is already up to date.</p>
  
  <p>Most results for this specific <code>TypeError: eslint.CLIEngine is not a constructor</code> error claim <a href="https://github.com/babel/eslint-plugin-babel/issues/140" rel="noreferrer">the user should upgrade their JetBrains IDE</a>. However, I am running <code>vue-cli-service build</code> on the command line and not using JetBrains.</p>
  
  <p>The code referred to by the error message is (with preceding context):</p>
  
  <p><strong>MYPATH/node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>...
  var config = assign(
      // loader defaults
      {
        cacheIdentifier: JSON.stringify({
          "eslint-loader": pkg.version,
          eslint: eslintVersion || "unknown version"
        }),
        eslintPath: "eslint"
      },
      userOptions
    );
  
    if (typeof config.formatter === "string") {
      try {
        config.formatter = require(config.formatter);
        if (
          config.formatter &amp;&amp;
          typeof config.formatter !== "function" &amp;&amp;
          typeof config.formatter.default === "function"
        ) {
          config.formatter = config.formatter.default;
        }
      } catch (_) {
        // ignored
      }
    }
  
    var cacheDirectory = config.cache;
    var cacheIdentifier = config.cacheIdentifier;
  
    delete config.cacheIdentifier;
  
    // Create the engine only once per config
    var configHash = objectHash(config);
  
    if (!engines[configHash]) {
      var eslint = require(config.eslintPath);
      engines[configHash] = new eslint.CLIEngine(config); //Error happens here
    }
  ...
  </code></pre>
  
  <p>Edit: I upgraded <code>@vue/cli-plugin-eslint</code> from version 3.11.0 to 4.1.2 by editing yarn's <code>package.json</code>, at the suggestion of @DelenaMalan below. The build still fails with error: </p>
  
  <pre><code>ERROR  Failed to compile with 1 errors                                                                                                            7:51:01 PM
  
  Module build failed (from ./node_modules/@vue/cli-service/node_modules/thread-loader/dist/cjs.js):
  Thread Loader (Worker 0)
  eslint.CLIEngine is not a constructor
      at PoolWorker.fromErrorObj (MYPATH/node_modules/@vue/cli-service/node_modules/thread-loader/dist/WorkerPool.js:262:12)
      at MYPATH/node_modules/@vue/cli-service/node_modules/thread-loader/dist/WorkerPool.js:204:29
      at mapSeries (MYPATH/node_modules/neo-async/async.js:3625:14)
      at PoolWorker.onWorkerMessage (MYPATH/node_modules/@vue/cli-service/node_modules/thread-loader/dist/WorkerPool.js:170:35)
      at readBuffer (MYPATH/node_modules/@vue/cli-service/node_modules/thread-loader/dist/WorkerPool.js:152:14)
      at Object.module.exports (MYPATH/node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js:223:27)
  
  You may use special comments to disable some warnings.
  Use // eslint-disable-next-line to ignore the next line.
  Use /* eslint-disable */ to ignore all warnings in a file.
   ERROR  Build failed with errors.
  error Command failed with exit code 1.
  
  </code></pre>
  
  <p>Edit 2:
  I deleted and reinstalled the node modules on the repro linked <a href="https://github.com/aTegart/yarn-vue-eslint" rel="noreferrer">here</a>, as recommended by @CGundlach, but I still have the <code>eslint.CLIEngine is not a constructor</code> error</p>
  
  <pre><code>Annas-MacBook-Pro:eslint-test-project anna$ rm -rf node_modules/
  Annas-MacBook-Pro:eslint-test-project anna$ yarn install
  yarn install v1.21.1
  [1/4]   Resolving packages...
  [2/4]   Fetching packages...
  [3/4]   Linking dependencies...
  warning "@vue/eslint-config-airbnb &gt; eslint-import-resolver-webpack@0.11.1" has unmet peer dependency "webpack@&gt;=1.11.0".
  [4/4]   Building fresh packages...
  ✨  Done in 14.14s.
  Annas-MacBook-Pro:eslint-test-project anna$ yarn build
  yarn run v1.21.1
  $ vue-cli-service build
  
  ⠏  Building for production...
  
   ERROR  Failed to compile with 1 errors                                                                                                           12:28:32 PM
  
  Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
  Thread Loader (Worker 0)
  eslint.CLIEngine is not a constructor
      at PoolWorker.fromErrorObj (/Users/anna/projects/yarn-vue-eslint/eslint-test-project/node_modules/thread-loader/dist/WorkerPool.js:262:12)
      at /Users/anna/projects/yarn-vue-eslint/eslint-test-project/node_modules/thread-loader/dist/WorkerPool.js:204:29
      at mapSeries (/Users/anna/projects/yarn-vue-eslint/eslint-test-project/node_modules/neo-async/async.js:3625:14)
      at PoolWorker.onWorkerMessage (/Users/anna/projects/yarn-vue-eslint/eslint-test-project/node_modules/thread-loader/dist/WorkerPool.js:170:35)
      at readBuffer (/Users/anna/projects/yarn-vue-eslint/eslint-test-project/node_modules/thread-loader/dist/WorkerPool.js:152:14)
      at Object.module.exports (/Users/anna/projects/yarn-vue-eslint/eslint-test-project/node_modules/eslint-loader/index.js:223:27)
  
  You may use special comments to disable some warnings.
  Use // eslint-disable-next-line to ignore the next line.
  Use /* eslint-disable */ to ignore all warnings in a file.
   ERROR  Build failed with errors.
  error Command failed with exit code 1.
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  </code></pre>