最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - "Syntax Error: Error: No ESLint configuration found in" when I tried to npm run serve a project I

programmeradmin1浏览0评论

I tried downloading and running a Vue.js project from GitHub that was sent to me, but as soon as I tried npm run serve, I got the following error:

Syntax Error: Error: No ESLint configuration found in C:\Users\User\Desktop\movies-main\src.

I ran npm install too beforehand. I've create a couple of Vue.js projects myself and have never had this error so I'm not sure how to solve it. Could I be missing a dependency on my machine or something? I haven't used ESLint before.

I tried downloading and running a Vue.js project from GitHub that was sent to me, but as soon as I tried npm run serve, I got the following error:

Syntax Error: Error: No ESLint configuration found in C:\Users\User\Desktop\movies-main\src.

I ran npm install too beforehand. I've create a couple of Vue.js projects myself and have never had this error so I'm not sure how to solve it. Could I be missing a dependency on my machine or something? I haven't used ESLint before.

Share Improve this question edited Feb 15, 2021 at 20:51 Onyx asked Feb 15, 2021 at 20:40 OnyxOnyx 5,77210 gold badges52 silver badges119 bronze badges 3
  • 1 is there a ESlint configuration? this should be a file like .eslintrc.js – Serg Commented Feb 15, 2021 at 22:14
  • @Serg There isn't. – Onyx Commented Feb 15, 2021 at 22:37
  • It means there is not eslint configuration, Check this if you want to set it. eslint.org/docs/user-guide/configuring if you want to disable it check this (You should not in my opinion). github.com/vuejs-templates/webpack/issues/73 – Nik Commented Feb 16, 2021 at 4:32
Add a comment  | 

5 Answers 5

Reset to default 8

Open your project folder. Then run the following command

npm install eslint -g -D

Then finish by typing :

eslint --init

Solve the problem for me.

Or use the locally installed eslint

npm init @eslint/config

I was getting this error after symlinking an NPM library via npm link in the library directory followed by npm link <library name> in the consuming Vue+Vite application.

Vite may be important information because the error stemmed from vite-plugin-eslint.

I fixed it by passing in include key for the eslint options:

vite.config.js

import eslint from 'vite-plugin-eslint';
import path from 'path';
// side note: `path` might require node v16+ due to `node:path` import

...

export default defineConfig({
    plugins: [
        eslint({
            // without explicit path resolve, eslint tries to lint external directories symlinked via `npm link`
            include: [
                `${path.resolve(__dirname, '')}/**/*.js`,
                `${path.resolve(__dirname, '')}/**/*.vue`,
            ],
        }),

If you look at the docs, you'll see the default eslint() with no options passed in (as recommended by their plugin) causes include: ['**/*.ext'], so the solution here is to change **/ to /explicit/path/to/root/of/your/project/.

In hypothesis, you could also use the exclude key of the eslint options and stop it from trying to lint external folders, but I don't prefer that solution in case of multiple developers because you cannot predict their directory structure.

according to the document of eslint Open the root of your project then use this command:

npm init @eslint/config

it will create an eslintrc in the root of the project. this way helped me to solve the problem.

Without installing eslint use npx

npx eslint --init
发布评论

评论列表(0)

  1. 暂无评论