[英]How to solve no such file or directory 'router.js'
I was working on my Nuxt project, when after adding a new file.vue, i had this error: 添加新file.vue之后,我正在处理Nuxt项目,出现以下错误:
Failed to compile with 1 errors friendly-errors 16:19:30
ERROR in ./.nuxt/router.js friendly-errors 16:19:30
Module build failed (from ./node_modules/eslint-loader/index.js): friendly-errors 16:19:30
Error: ENOENT: no such file or directory, open '/Users/jacopotabani/Desktop/my-movie-app-PWA-v2/.nuxt/router.js
If i look in the folder .nuxt, the file 'router.js'disappeared. 如果我在文件夹.nuxt中查找,则文件“ router.js”消失。 I have tried to copy the router.js file from a copy of the project that i had made before, but after reloading the app, the file 'router.js' changes automatically in 'router 4.js'. 我试图从以前制作的项目的副本中复制router.js文件,但是重新加载应用程序后,文件“ router.js”在“ router 4.js”中会自动更改。
How can i solve? 我该如何解决?
When you are using Nuxt.js
, typically you should use pages
directory, that Nuxt
uses to generate router config object. 当使用Nuxt.js
,通常应使用pages
目录,该目录是Nuxt
用来生成路由器配置对象的。 Reference 参考
Nuxt.js
automatically generates thevue-router
configuration based on your file tree of Vue files inside thepages
directory.Nuxt.js
根据您在pages
目录内的Vue文件的文件树自动生成vue-router
配置。
For example, let's consider that you have following file tree: 例如,让我们考虑您具有以下文件树:
pages/
--| user/
-----| index.vue
-----| one.vue
--| index.vue
Following router config will be generated: 将生成以下路由器配置:
router: {
routes: [
{
name: 'index',
path: '/',
component: 'pages/index.vue'
},
{
name: 'user',
path: '/user',
component: 'pages/user/index.vue'
},
{
name: 'user-one',
path: '/user/one',
component: 'pages/user/one.vue'
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.