所有Vue命令都返回"未知命令"

Com*_*tch 1 ubuntu vue.js

在Ubuntu 18.04上使用Vue 2.9.4,所有命令都返回错误"Unknown command"

compustretch@instance-1:~/vuetest$ vue init webpack testapp

  Unknown command init.

  vue-cli · Failed to download repo vuejs-templates/[object Object]: Response code 404 (Not Found)

compustretch@instance-1:~/vuetest$ vue list

  Unknown command list.

  Available official templates:

  ?  browserify - A full-featured Browserify + vueify setup with hot-reload, linting & unit testing.
  ?  browserify-simple - A simple Browserify + vueify setup for quick prototyping.
  ?  pwa - PWA template for vue-cli based on the webpack template
  ?  simple - The simplest possible Vue setup in a single HTML file
  ?  webpack - A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.
  ?  webpack-simple - A simple Webpack + vue-loader setup for quick prototyping.

compustretch@instance-1:~/vuetest$ vue help init

  Unknown command help.

  vue-[object Object](1) does not exist, try --help

compustretch@instance-1:~/vuetest$ vue --version
2.9.4
compustretch@instance-1:~/vuetest$
Run Code Online (Sandbox Code Playgroud)

希望有人知道为什么会发生这种情况,因为我一直在抨击这个问题,搜索结果根本就没有.

Iva*_*van 8

您需要使用此命令卸载 npm uninstall -g vue-cli

然后使用以下命令安装v3 npm install -g @vue/cli(不确定为什么他们使用当前的2.9.4版本)

此外,他们还会要求您安装额外的东西,如init,list等

更新:

忘记npm install -g @vue/cli因为它仍然是测试版,当你使用像nuxt这样的其他库时,它会给你带来很多问题.

我建议你尝试这个命令npm install -g vue-cli@2.9.3它会为你节省很多头条.