Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vetur can't find package.json

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

like image 536
Cmanar0 Avatar asked Apr 07 '21 12:04

Cmanar0


People also ask

Why doesn't VeTur know the version of my Vue project?

Vetur can't find package.json in /xxxx/xxxxxx. If you don't have any package.json in your project, Vetur can't know the Vue version and component data from other libs. Vetur assumes that the version of Vue is less than 2.5.

Why is VeTur not working on my project?

to help us find the cause of the issue. Vetur can't find tsconfig.json, jsconfig.json in /xxxx/xxxxxx. If you don't have any tsconfig.json, jsconfig.json in your project, Vetur will use fallback settings. Some features such as including path alias, decorator, and import json won't work.

Why can't I find <some-module> in VeTur's installation directory?

If it says cannot find module <some-module>, go to Vetur's client code installation directory and run yarn or npm install . This is usually caused by VS Code not correctly updating Vetur's dependencies from version to version. Paths: You can also try uninstall/reinstall Vetur. . For example:

How to get debug info from VeTur?

If you want debug info, you can use Vetur: show doctor info command. You can use vetur.ignoreProjectWarning: true in vscode setting to close this warning. ⚠️ Notice ⚠️ : If you don't need (path alias/decorator/import json) feature, you can just close it. Vetur can't find package.json in /xxxx/xxxxxx.


Video Answer


4 Answers

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!

like image 175
bangeboss Avatar answered Nov 09 '22 23:11

bangeboss


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!

like image 27
Marcos Mendes Avatar answered Nov 10 '22 01:11

Marcos Mendes


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'
      ]
    }
  ]
}
like image 32
Kai - Kazuya Ito Avatar answered Nov 09 '22 23:11

Kai - Kazuya Ito


in VSCode

ctrl + p
open setting.json
add this line:

  "vetur.ignoreProjectWarning": true,

this will ignore the error.

like image 40
Amir Khadem Avatar answered Nov 10 '22 00:11

Amir Khadem