vue-cli: New vue-cli application fails to compile due to eslint-loader
Version
3.9.0
Environment info
Environment Info:
System:
OS: macOS Sierra 10.12.6
CPU: (4) x64 Intel(R) Core(TM) i5-6287U CPU @ 3.10GHz
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
Browsers:
Chrome: 75.0.3770.100
Firefox: 67.0.4
Safari: 12.1.1
npmPackages:
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.0.0
@vue/babel-preset-app: 3.9.0
@vue/babel-preset-jsx: 1.0.0
@vue/babel-sugar-functional-vue: 1.0.0
@vue/babel-sugar-inject-h: 1.0.0
@vue/babel-sugar-v-model: 1.0.0
@vue/babel-sugar-v-on: 1.0.0
@vue/cli-overlay: 3.9.0
@vue/cli-plugin-babel: ^3.9.0 => 3.9.0
@vue/cli-plugin-eslint: ^3.9.0 => 3.9.0
@vue/cli-service: ^3.9.0 => 3.9.0
@vue/cli-shared-utils: 3.9.0
@vue/component-compiler-utils: 2.6.0
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^5.0.0 => 5.2.3 (4.7.1)
vue: ^2.6.10 => 2.6.10
vue-eslint-parser: 2.0.3 (5.0.0)
vue-hot-reload-api: 2.3.3
vue-loader: 15.7.0
vue-router: ^3.0.3 => 3.0.7
vue-style-loader: 4.1.2
vue-template-compiler: ^2.6.10 => 2.6.10
vue-template-es2015-compiler: 1.9.1
vuex: ^3.0.1 => 3.1.1
npmGlobalPackages:
@vue/cli: 3.9.0
Steps to reproduce
>vue create new-app
>cd new-app
>npm run serve
What is expected?
INFO Starting development server...
98% after emitting CopyPlugin .
DONE Compiled successfully in 3435ms 10:02:58 AM
App running at:
- Local: http://localhost:8080/
- Network: http://10.145.82.231:8080/
Note that the development build is not optimized.
To create a production build, run npm run build.
What is actually happening?
INFO Starting development server...
98% after emitting CopyPlugin
ERROR Failed to compile with 1 errors 9:53:57 AM
Module build failed (from ./node_modules/eslint-loader/index.js):
Error: Cannot find module '.../node_modules/eslint/lib/api.js/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.module.exports (.../node_modules/eslint-loader/index.js:170:23)
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.
This is from a clean instantiation of a vue-cli application. No additional configuration to webpack or eslint. It had been working previously, so I’m thinking it could be a issue caused by a minor update to a dependency. Somewhere eslint-loader is getting a user defined eslint package path that does not exist.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 78
- Comments: 44 (7 by maintainers)
Commits related to this issue
- fix: use module directory instead of main entry path for `eslintPath` fixes #4231 — committed to sodatea/vue-cli by sodatea 5 years ago
- temp fix for https://github.com/vuejs/vue-cli/issues/4231 — committed to MyEtherWallet/MyEtherWallet by kvhnuke 5 years ago
- fix: use module directory instead of entry file for `eslintPath` (#4233) fixes #4231 — committed to vuejs/vue-cli by sodatea 5 years ago
- fix: use module directory instead of entry file for `eslintPath` (#4233) fixes #4231 (cherry picked from commit 992fe0790d0a086225d6e94d220b67bad306d121) — committed to vuejs/vue-cli by sodatea 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to PanJiaChen/vue-element-admin by itsccn 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to PanJiaChen/vue-element-admin by itsccn 5 years ago
- 安装npm i eslint-loader@2.1.2解决报错 https://github.com/vuejs/vue-cli/issues/4231 — committed to lcolok/smc by lcolok 4 years ago
- feat: Update fork repository (#514) * chore: remove i18n (#1828) * [release] 4.1.0 * perf[Profile]: adapt the profile page to the mobile (#2020) * Revert "perf: optimize page scrolling when ... — committed to adempiere/adempiere-vue by deleted user 4 years ago
- 할일 추가, 삭제, 목록 제작 — committed to dev-jinheekim/study-vue by deleted user 4 years ago
- removed meaningless eslint-loader error by doing some walkaround. https://github.com/vuejs/vue-cli/issues/4231 — committed to hulululuh/MemeNgin by hulululuh 4 years ago
- feat: Update repository (#580) * chore: remove i18n (#1828) * [release] 4.1.0 * perf[Profile]: adapt the profile page to the mobile (#2020) * Revert "perf: optimize page scrolling when setti... — committed to adempiere/adempiere-vue by EdwinBetanc0urt 3 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to iGuru-T/vue-element-admin by iGuru-T 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to B-Guru/vue-element-admin by B-Guru 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to CoinDev1121/vue-element-admin by CoinDev1121 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to coin-monster/vue-element-admin by coin-monster 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to pvtrong/vue-element-admin by itsccn 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to anteroselin/vue-element-admin by itsccn 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to Jarosky/vue-element-admin by itsccn 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to trent081/admin-dashboard-vue by itsccn 5 years ago
- bump: update @vue/cli-plugin-eslint version (#2327) FIx cannot find module '.../node_modules/eslint/lib/api.js/package.json' bug,see https://github.com/vuejs/vue-cli/issues/4231. — committed to FPLeader/vue-element-admin by FPLeader 5 years ago
As @ikitozen mentioned
"resolutions": { "eslint-loader": "2.1.2" }
in package.json seems to do the trick.
For npm users it should just be
npm i eslint-loader@2.1.2
right?Another workaround would probably be to disable lintOnSave:
which should keep webpack from loading eslint-loader in the first place.
I prefer lint on commit anyway.
not fixed by
npm i eslint-loader@2.1.2
@mudin Maybe you need to clear the npm cache or manually change the
@vue/cli-plugin-eslint
version inpackage.json
to^3.9.1
you will have to remove
/node_modules
andpackage-lock.json
first, then add e: slint-loader to your package.json as a devDependency:then run npm install again and this time, the cli-plugin-eslint should end up with the older, working version.
Once eslint-loader has been fixed you can remove that dependency, and reinstall all packages again.
For anyone else diving into it, I think it’s related to this change in eslint-loader that was meant to help support eslint 6. It’s adding
/package.json
in situations where theuserEslintPath
seems to already be a file rather than a directory. This is resulting in eslint-loader trying to find the.../api.js/package.json
path.https://github.com/webpack-contrib/eslint-loader/commit/b6c3938aae61c0390ac8d941af50cf36df14cfc3#diff-168726dbe96b3ce427e7fedce31bb0bcR167
Same issue here as well. I created an issue similar to this one but on the
vuejs/vue
repository which I was told to come here.OS: Windows 7 Ultimate Service Pack 1 node -v: v8.11.3 npm -v: 6.9.0 vue -V: 3.9.0
npm run serve
hi, where´s the vue.config.js?
@sodatea yeah!!! I’ve cleared cache and success now! thanks The issue is fixed in version 3.9.1!
Sorry for the inconvenience. We did a quick fix to work around the buggy behavior of eslint-loader v2.2. So this issue should have been fixed now.
I could have it fixed earlier but at that time I was too sleepy to wait for the CI results to come out. So sorry for that 😂😂Also receiving this compile error after updating to v.3.9.0. Reverted to eslint-loader@2.1.2 per @maxql’s response.
更新到 3.9.0后,创建的项目,执行: npm run serve,出现下面错误:
Module build failed (from ./node_modules/eslint-loader/index.js): Error: Cannot find module ‘…/node_modules/eslint/lib/api.js/package.json’ at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.module.exports (…/node_modules/eslint-loader/index.js:170:23)
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.
怎么解决啊。
– it’s ok npm i eslint-loader@2.1.2
same issue here, fixed by freezing eslint-loader to version 2.1.2 for now
Looks like a eslint-loader 2.2.0 issue https://github.com/webpack-contrib/eslint-loader/commit/b6c3938aae61c0390ac8d941af50cf36df14cfc3
For nuxt users and encountered this error, if you don’t need eslint and want to save time. Just remove the ‘@nuxtjs/eslint-module’ in nuxt.config.js
buildModules: [
same problem here ofc after update! Works by doing npm i eslint-loader@2.1.2. Looking forward to fix! 😃