vuejs / vetur

Vue tooling for VS Code.
https://vuejs.github.io/vetur/
MIT License
5.75k stars 593 forks source link

Vue Language Server crashed (again?) #286

Closed eneim closed 7 years ago

eneim commented 7 years ago

Problem

Since this is quite common error (base on my searching result), I will just put the log as below:

/Users/eneim/.vscode/extensions/octref.vetur-0.8.5/client/node_modules/vue-template-compiler/index.js:8
  throw new Error(
  ^

Error: 

Vue packages version mismatch:

- vue@2.3.3
- vue-template-compiler@2.3.4

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

    at Object.<anonymous> (/Users/eneim/.vscode/extensions/octref.vetur-0.8.5/client/node_modules/vue-template-compiler/index.js:8:9)
    at Object.<anonymous> (/Users/eneim/.vscode/extensions/octref.vetur-0.8.5/client/node_modules/vue-template-compiler/index.js:20:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/eneim/.vscode/extensions/octref.vetur-0.8.5/client/node_modules/vue-language-server/dist/modes/script/typescript.js:5:31)
[Error - 10:20:33 AM] Connection to server got closed. Server will not be restarted.

Reproducible Case

I have a vue app NOT using typescript, with be dependencies looks like this

"dependencies": {
    "material-components-web": "^0.13.0",
    "vue": "^2.0.1",
    "vue-resource": "^1.3.3",
    "vue-router": "^2.3.0"
  },
  "devDependencies": {
    "babel-core": "^6.0.0",
    "babel-preset-es2015": "^6.0.0",
    "babelify": "^7.2.0",
    "browserify": "^13.0.1",
    "browserify-hmr": "^0.3.1",
    "cross-env": "^1.0.6",
    "envify": "^3.4.1",
    "http-server": "^0.9.0",
    "node-sass": "^4.5.3",
    "npm-run-all": "^2.1.2",
    "rxjs": "^5.4.1",
    "uglify-js": "^2.5.0",
    "vueify": "^9.1.0",
    "watchify": "^3.4.0"
  },
  "browserify": {
    "transform": [
      "vueify",
      "babelify"
    ]
  }

Everytime I open vscode it will crash the server after a few seconds (time for some retries I guess).

I search around and see the same thing for older version as well. But neither of them seems to have a final solution. I have already go into extension folder, remove node_modules and run npm install against it but having no luck.

All dependencies suppose to be installed with latest available version, so vue and vue-template-compiler are all 2.3.4 (I also run npm ls to double check).

Please help.

HerringtonDarkholme commented 7 years ago

Please wait for 0.8.6.

For now you can try go into extension folder, fire up node, and try require('vue')

It should not get any vue result. Otherwise some modules are wrongly required.

eneim commented 7 years ago

@HerringtonDarkholme Got it. Hopefully 0.8.6 or few next major release will completely fix this issue. Thanks for the beautiful extension.

octref commented 7 years ago

The confusion comes from the problem was fixed, reintroduced when merging a PR, and fixed again now...Sorry for the bad experience.

I released 0.8.6 which should fix the problem.

octref commented 7 years ago

will completely fix this issue

Yep, we don't use vue-template-compiler anymore so this issue should be completely gone.

HerringtonDarkholme commented 7 years ago

@octref do you have any idea why vue is wrongly required? We don't have it in package.json. So if it is wrongly required, it might be a bug of vscode.

HerringtonDarkholme commented 7 years ago

@eneim Can you try require('vue') inside the extension folder?

octref commented 7 years ago

I'm not 100% sure, but my guess is this has something to do with the globally installed vue-cli, which includes a version of vue and vue-template-compiler.

Just checked, latest vue-cli@2.8.2 has vue@2.3.3. I don't know the exact reason, though.

eneim commented 7 years ago

@HerringtonDarkholme I go directly into extension client folder, from client folder, I run npm install vue (which will add vue into the node_modules) and it works for me.

eneim commented 7 years ago
HerringtonDarkholme commented 7 years ago

Well, let's just close this. Since vue-template-compiler is deliberately designed for small foot-print for browser usage. It is definitely not for editor usage which requires AST traversal, error recovery, AST node location and so on.

Removing it is the best choice.