3

So I've been setting up projects with the Vue CLI 3.0.0rc8 and it is a pretty awesome tool but I have a problem. I am trying to install the router plugin for my project however when I use vue add router, I get this:

(node:2706) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'routerHistoryMode' of undefined
at module.exports (/home/joshua/programs/firstwebapp/frontend/node_modules/@vue/cli-service/generator/router/index.js:10:26)
at Generator.plugins.forEach (/home/joshua/.node_modules_global/lib/node_modules/@vue/cli/lib/Generator.js:96:7)
at Array.forEach (<anonymous>)
at new Generator (/home/joshua/.node_modules_global/lib/node_modules/@vue/cli/lib/Generator.js:94:13)
at Function.runGenerator (/home/joshua/.node_modules_global/lib/node_modules/@vue/cli/lib/invoke.js:111:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2706) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2706) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Could someone please explain why this isn't working?

P.S. I've also tried vue add @vue/router and I get the same message.

4
  • Are you in the root of the project when you do that command 'vue add router'? Error doesnt give much of clue whats going on. Commented Aug 5, 2018 at 9:51
  • @josip Yes I made sure that I was in the root directory. I feel like this may be a bug with the vue CLI. Commented Aug 5, 2018 at 14:30
  • @JoshuaAvery yes seem to be right, i'we created new project with Vue cli 3.0.0rc3 and i get the same error when trying to 'vue add router'. Commented Aug 5, 2018 at 14:58
  • @josip I've figured it out and I posted my answer. Commented Aug 5, 2018 at 15:20

2 Answers 2

3

I've got it! Thank you to @dnhyde for your suggestion. But if you actually want to install it as a plugin you need to update the Vue CLI to 3.0.0-rc.10. Do so with this command: npm i -g @vue/cli.

Sign up to request clarification or add additional context in comments.

Comments

0

Hi I had a similar issue, the best way to add Vue router in my case was to select it from the start with vue create my-project command. Or you can manually add the router.js file and the Vue.use(router) in your main following the template vue-cli creates for you.

1 Comment

Where would I find the router.js file? Would I npm install vue-router? However wouldn't this be loading the library used with the older CLI? Would I be able to find the actual CLI 3 plugin source somewhere? Or is there any difference?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.