Vue-cli: Error when adding vue-router via CLI UI

Created on 2 Aug 2018  ·  8Comments  ·  Source: vuejs/vue-cli

Version

3.0.0-rc.10

Node and OS info

node v8.9.4 / npm 5.6.0 / Windows 10

Steps to reproduce

vue ui

创建项目

添加vue-router插件

What is expected?

正常添加vue-router

What is actually happening?

TypeError: Cannot read property 'routerHistoryMode' of undefined
at module.exports (D:\dev\myself\config-ui\node_modules\@vue\cli-service\generator\router\index.js:10:26)
at Generator.plugins.forEach (C:\Users\zhangsan\AppData\Roaming\npm\node_modules\@vue\cli\lib\Generator.js:96:7)
at Array.forEach ()
at new Generator (C:\Users\zhangsan\AppData\Roaming\npm\node_modules\@vue\cli\lib\Generator.js:94:13)
at Function.runGenerator (C:\Users\zhangsan\AppData\Roaming\npm\node_modules\@vue\cli\lib\invoke.js:111:21)
at
at process._tickCallback (internal/process/next_tick.js:188:7)

needs team repro ui

Most helpful comment

@Akryum I added a new option (history mode) for the router generator in 6392a609 that led to this issue, and I pushed a temporary fix in 128d9d92. We probably want to add a prompt for this option when adding router from the UI.

All 8 comments

I had the same error on ui, and I was able to solve it by cli.

$ vue add router
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes

🚀  Invoking generator for core:router...
📦  Installing additional dependencies...

yarn install v1.6.0
(node:6717) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 2.43s.
✔  Successfully invoked generator for plugin: core:router
   The following files have been updated / added:
⠁
     src/router.js
     src/views/About.vue
     src/views/Home.vue
     package.json
     src/App.vue
     src/main.js
     yarn.lock

   You should review these changes with git diff and commit them.

@Akryum I added a new option (history mode) for the router generator in 6392a609 that led to this issue, and I pushed a temporary fix in 128d9d92. We probably want to add a prompt for this option when adding router from the UI.

@yyx990803 非常感谢!

Had the same error right now. Restarting the vue ui did solve the issue.

same error with vue 3.0.0-rc.3 any workaround available?

🚀  Starting GUI...
🌠  Ready on http://localhost:8000
TypeError: Cannot read property 'routerHistoryMode' of undefined
    at module.exports (/Users/d023280/Documents/workspace/exhibition/ex-frontend/ex-frontend/node_modules/@vue/cli-service/generator/router.js:3:26)
    at /Users/d023280/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:51:7
    at Array.forEach (<anonymous>)
    at new Generator (/Users/d023280/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:49:13)
    at Function.runGenerator (/Users/d023280/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:101:21)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async install (/Users/d023280/.config/yarn/global/node_modules/@vue/cli-ui/ui-defaults/suggestions.js:82:5)
    at async Object.handler (/Users/d023280/.config/yarn/global/node_modules/@vue/cli-ui/ui-defaults/suggestions.js:19:13)
    at async Object.activate (/Users/d023280/.config/yarn/global/node_modules/@vue/cli-ui/src/graphql-api/connectors/suggestions.js:82:14)

@freegroup Please upgrade your global Vue CLI installation to either 4.0.5 or 3.12.1.
3.0.0-rc.3 is way too old and a lot of bugs has been fixed since that version.

I have this error on version 4.3.1 is the vue-router installation only for version 4.0.5 or 3.12.1 ?

Please open a new issue with a reproduction project and detailed error messages

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BusyHe picture BusyHe  ·  3Comments

eladcandroid picture eladcandroid  ·  3Comments

sanderswang picture sanderswang  ·  3Comments

Gonzalo2683 picture Gonzalo2683  ·  3Comments

CodeApePro picture CodeApePro  ·  3Comments