NUXT:无法编译模板 [英] NUXT: Could not compile template
问题描述
我正在开始使用 nuxt.我在屏幕截图中的项目结构,我有一个 vuetify carousel 组件,它可以很好地使用 url 作为 src.现在我想尝试提供本地静态文件.我试过了:
I'm getting started with nuxt. My project structure in the screenshot, I've got a vuetify carousel component that was working fine with urls as the src. Now I want to try to serve local static files. I tried:
<template>
<v-carousel>
<v-carousel-item v-for="(item,i) in items" :key="i" :src="item.src"></v-carousel-item>
</v-carousel>
</template>
<script>
export default {
data () {
return {
items: [
{
src: '/static/52lv.PNG'
},
{
src: 'https://cdn.vuetifyjs.com/images/carousel/sky.jpg'
},
{
src: 'https://cdn.vuetifyjs.com/images/carousel/bird.jpg'
},
{
src: 'https://cdn.vuetifyjs.com/images/carousel/planet.jpg'
}
]
}
}
}
</script>
但是现在当我运行开发服务器时,我得到:
but now when I run the dev server I get:
$ npm run dev
> nuxt4@1.0.0 dev ....\js\nuxt4
> nuxt
i Preparing project for development 20:23:25
i Initial build may take a while 20:23:25
√ Builder initialized 20:23:25
ERROR Could not compile template ....nuxt4\\node_modules\\@nuxt\\vue-app\\template\\App.js: Cannot resolve "~/assets/style/app.styl" from "E:\ENVS\js\nuxt4\assets\style\app.styl"
at Promise.all.templatesFiles.map (node_modules\@nuxt\builder\dist\builder.js:6009:17)
我做错了什么?
推荐答案
我遇到了确切的问题,原来是我的 nuxt.config.js 文件中 css 和 scripts 部分下的路径问题.我添加了一个资产文件夹,其中包含子文件夹和文件,例如 static > assets > etc 但在我的配置文件中它是 ~/assets.
I had the exact issue, it turned out to be a path issue in my nuxt.config.js file under css and scripts sections. I added a assets folder with sub folders and files within them such as static > assets > etc but in my config file it was ~/assets.
我将其更改为 ~/static/assets/,现在它可以正确编译.
I changed it to ~/static/assets/ and now it compiles correctly.
希望这会有所帮助.
这篇关于NUXT:无法编译模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!