Skip to content

Commit 85c9cbf

Browse files
authored
fix: fix eslint not found error in vue serve command (#4728)
1 parent d82a2bb commit 85c9cbf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/@vue/cli-plugin-eslint/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ module.exports = (api, options) => {
66
// Use loadModule to allow users to customize their ESLint dependency version.
77
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')
88
const cwd = api.getCwd()
9-
const eslintPkg = loadModule('eslint/package.json', cwd, true)
9+
const eslintPkg =
10+
loadModule('eslint/package.json', cwd, true) ||
11+
loadModule('eslint/package.json', __dirname, true)
1012

1113
// eslint-loader doesn't bust cache when eslint config changes
1214
// so we have to manually generate a cache identifier that takes the config
@@ -28,10 +30,6 @@ module.exports = (api, options) => {
2830
)
2931

3032
api.chainWebpack(webpackConfig => {
31-
webpackConfig.resolveLoader.modules.prepend(
32-
path.join(__dirname, 'node_modules')
33-
)
34-
3533
const { lintOnSave } = options
3634
const allWarnings = lintOnSave === true || lintOnSave === 'warning'
3735
const allErrors = lintOnSave === 'error'
@@ -45,7 +43,7 @@ module.exports = (api, options) => {
4543
.end()
4644
.test(/\.(vue|(j|t)sx?)$/)
4745
.use('eslint-loader')
48-
.loader('eslint-loader')
46+
.loader(require.resolve('eslint-loader'))
4947
.options({
5048
extensions,
5149
cache: true,

0 commit comments

Comments
 (0)