Vetur can't find package.json

15,026

Solution 1

Installing the EsLint extension should solve your problem

if you are on VS Code, search for the EsLint extension by publisher:"Dirk Baeumer", install it and approve the installation to start the EsLint server

Alternatively run this in the terminal npm install eslint in your workspace

The package.json file gets modified and your server will be up again

for further information on the EsLint extension you can check https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

Good luck!

Solution 2

Add "vetur.config.js" outside your project.

In this example below, "vetur.config.js" is added outside the project "vueProject":

enter image description here

Shrinking "vueProject" looks clearer:

enter image description here

Then, paste this code below to "vetur.config.js":

// vetur.config.js
/** @type {import('vls').VeturConfig} */
module.exports = {
  // **optional** default: `{}`
  // override vscode settings
  // Notice: It only affects the settings used by Vetur.
  settings: {
    "vetur.useWorkspaceDependencies": true,
    "vetur.experimental.templateInterpolationService": true
  },
  // **optional** default: `[{ root: './' }]`
  // support monorepos
  projects: [
    './packages/repo2', // shorthand for only root.
    {
      // **required**
      // Where is your project?
      // It is relative to `vetur.config.js`.
      root: './packages/repo1',
      // **optional** default: `'package.json'`
      // Where is `package.json` in the project?
      // We use it to determine the version of vue.
      // It is relative to root property.
      package: './package.json',
      // **optional**
      // Where is TypeScript config file in the project?
      // It is relative to root property.
      tsconfig: './tsconfig.json',
      // **optional** default: `'./.vscode/vetur/snippets'`
      // Where is vetur custom snippets folders?
      snippetFolder: './.vscode/vetur/snippets',
      // **optional** default: `[]`
      // Register globally Vue component glob.
      // If you set it, you can get completion by that components.
      // It is relative to root property.
      // Notice: It won't actually do it. You need to use `require.context` or `Vue.component`
      globalComponents: [
        './src/components/**/*.vue'
      ]
    }
  ]
}

Solution 3

First of all, in Visual Studio code, type:

Ctrl + Shift + p

This command, will open this window

enter image description here

Type: settings json in search bar, like this:

enter image description here

Open the first option: "Open Settings (JSON)".

Now, on JSON file, add this: "vetur.ignoreProjectWarning": true, in the end of file, like this:

enter image description here

Restart Visual Studio Code and you're done!

Solution 4

in VSCode

ctrl + p
open setting.json
add this line:

  "vetur.ignoreProjectWarning": true,

this will ignore the error.

Share:
15,026
Cmanar0
Author by

Cmanar0

Updated on July 28, 2022

Comments

  • Cmanar0
    Cmanar0 almost 2 years

    I was writing code for my app with Vue and everything worked perfectly. Then I started to create child components and I could not refresh the localhost anymore.

    Now it says:

    "Vetur can't find 'package.json" & "Vetur can't find 'tsconfig.json' or 'jsconfig.json"

    and when I try to "npm run serve" in the cmd - then i get this:

    C:\Users\cmana\Desktop\WebDeveloper\Vue app\vuetify-todo>npm run serve
    npm ERR! code ENOENT
    npm ERR! syscall open
    npm ERR! path C:\Users\cmana\Desktop\WebDeveloper\Vue app\vuetify-todo\package.json
    npm ERR! errno -4058
    npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\cmana\Desktop\WebDeveloper\Vue app\vuetify-todo\package.json'
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent 
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\cmana\AppData\Roaming\npm-cache\_logs\2021-04-07T12_03_13_953Z-debug.log
    

    Acording to this https://vuejs.github.io/vetur/guide/setup.html#project-setup - I tried to add the jsconfig.json file with this content. (I deleted all the child components so I only have these vue files (About, Todo, App) left.)

    {
      "include": [
        "./src/views/About.vue",
        "./src/views/Todo.vue",
        "./src/App.vue"
      ]
    }
    

    Still nothing. Anybody any ideas? Thank you <3