From 85c9cbfedaee327a704cd9a3481833971e8bb8e8 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 21 Oct 2019 17:19:56 +0800 Subject: [PATCH] fix: fix eslint not found error in `vue serve` command (#4728) --- packages/@vue/cli-plugin-eslint/index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/@vue/cli-plugin-eslint/index.js b/packages/@vue/cli-plugin-eslint/index.js index 0051a0645f..addc5d0358 100644 --- a/packages/@vue/cli-plugin-eslint/index.js +++ b/packages/@vue/cli-plugin-eslint/index.js @@ -6,7 +6,9 @@ module.exports = (api, options) => { // Use loadModule to allow users to customize their ESLint dependency version. const { resolveModule, loadModule } = require('@vue/cli-shared-utils') const cwd = api.getCwd() - const eslintPkg = loadModule('eslint/package.json', cwd, true) + const eslintPkg = + loadModule('eslint/package.json', cwd, true) || + loadModule('eslint/package.json', __dirname, true) // eslint-loader doesn't bust cache when eslint config changes // so we have to manually generate a cache identifier that takes the config @@ -28,10 +30,6 @@ module.exports = (api, options) => { ) api.chainWebpack(webpackConfig => { - webpackConfig.resolveLoader.modules.prepend( - path.join(__dirname, 'node_modules') - ) - const { lintOnSave } = options const allWarnings = lintOnSave === true || lintOnSave === 'warning' const allErrors = lintOnSave === 'error' @@ -45,7 +43,7 @@ module.exports = (api, options) => { .end() .test(/\.(vue|(j|t)sx?)$/) .use('eslint-loader') - .loader('eslint-loader') + .loader(require.resolve('eslint-loader')) .options({ extensions, cache: true,