所以我一直在使用Vue CLI 3.0.0rc8设置项目,它是一个非常棒的工具,但我有一个问题。我正在尝试为我的项目安装路由器插件,但是当我使用vue add router
时,我得到了这个:
(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.
有没有人能解释一下为什么这个不起作用?
P.S.我也试过vue add @vue/router
,我得到了同样的信息。
发布于 2018-08-05 23:19:40
我有个主意!感谢@dnhyde的建议。但是如果你真的想把它作为一个插件安装,你需要把Vue CLI更新到3.0.0-rc.10。使用以下命令执行此操作:npm i -g @vue/cli
。
发布于 2018-08-05 19:10:58
嗨,我遇到了类似的问题,在我的例子中,添加Vue路由器的最好方法是从start with vue create my-project
命令中选择它。或者,您可以按照为您创建的模板vue-cli在main中手动添加router.js文件和Vue.use(router)
。
https://stackoverflow.com/questions/51691746
复制相似问题