Look at the Nuxt documentation to learn more.
Make sure to install dependencies:
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
Start the development server on http://localhost:3000:
# npm
npm run dev
# pnpm
pnpm dev
# yarn
yarn dev
# bun
bun run dev
Build the application for production:
# npm
npm run build
# pnpm
pnpm build
# yarn
yarn build
# bun
bun run build
Locally preview production build:
# npm
npm run preview
# pnpm
pnpm preview
# yarn
yarn preview
# bun
bun run preview
Check out the deployment documentation for more information.
问题描述:
在 app/pages/index.vue 文件中出现以下错误:
[Vetur Error] Line 2: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
问题代码:
<script setup lang="ts"> const { data: posts } = await useAsyncData('blog', () => queryCollection('blog').all()) </script>
解决方案:
tsconfig.json 文件中的配置module 选项设置为 'es2022'、'esnext'、'system'、'node16' 或 'nodenext'target 选项设置为 'es2017' 或更高版本推荐的 tsconfig.json 配置:
{
"compilerOptions": {
"module": "esnext",
"target": "es2017",
"moduleResolution": "node"
}
}
问题描述:
在 app/pages/index.vue 文件中出现以下错误:
[Vetur Error] Line 2: Cannot find name 'queryCollection'.
问题代码:
<script setup lang="ts"> const { data: posts } = await useAsyncData('blog', () => queryCollection('blog').all()) </script>
解决方案:
nuxt.config.ts 中添加 Nuxt Content 配置content.config.ts 文件是否正确配置安装 Nuxt Content:
npm install @nuxt/content
nuxt.config.ts 配置:
export default defineNuxtConfig({
modules: ['@nuxt/content'],
content: {
// 配置选项
}
})
vscode 中禁用 Vetur,启用 Volar 插件
npm run dev.nuxt 目录后重新启动