【问题标题】:@nuxt/content : currently no loaders are configured to process this file@nuxt/content : 目前没有配置加载器来处理这个文件
【发布时间】:2021-06-06 05:51:06
【问题描述】:

我已经安装了@nuxt/content,但是在运行npm run dev 时我收到了这个错误信息,尽管一切正常:

 WARN  in ./content/foo.md                                                                                                                        friendly-errors 11:36:40

Module parse failed: Assigning to rvalue (1:2)                                                                                                        friendly-errors 11:36:40
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> ---

我在安装过程中遗漏了什么吗?

我正在使用 node LTS v14.16.0npm 6.14.11

package.json:

{
  "name": "documentation",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
    "lint": "npm run lint:js"
  },
  "dependencies": {
    "@nuxt/content": "^1.14.0",
    "@nuxtjs/axios": "^5.13.1",
    "core-js": "^3.9.1",
    "nuxt": "^2.15.2"
  },
  "devDependencies": {
    "@nuxt/types": "^2.15.2",
    "@nuxt/typescript-build": "^2.1.0",
    "@nuxtjs/eslint-config": "^6.0.0",
    "@nuxtjs/eslint-config-typescript": "^6.0.0",
    "@nuxtjs/vuetify": "^1.11.3",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.21.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-nuxt": "^2.0.0",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-vue": "^7.7.0",
    "node-sass": "^5.0.0",
    "prettier": "^2.2.1",
    "sass-loader": "^10.1.1"
  }
}

nuxt.config.js:

export default {
  server: {
    host: process.env.HOST,
    port: process.env.PORT,
  },

  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    titleTemplate: '%s - documentation',
    title: 'My Doc',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: ['@/assets/css/main.css'],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  /*
   ** Plugins to load before mounting the App
   ** Doc: https://nuxtjs.org/guide/plugins
   */
  plugins: ['~/plugins/global.js'],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    // https://go.nuxtjs.dev/vuetify
    '@nuxtjs/vuetify',
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxt/content',
  ],

  // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  axios: {},

  content: {},

  // Vuetify module configuration (https://go.nuxtjs.dev/config-vuetify)
  vuetify: {
    customVariables: ['~/assets/variables.scss'],
  },

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {},
}

foo.md

---
title: Foo
description: Foo
---

# Hello World

【问题讨论】:

  • 如果您显示您的 foo.md 文件,可能会有用。里面有东西,需要加载吗?喜欢图片?
  • @FloWy 我已经更新了我的问题。这只是一个基本文件,如果它是空的,我会得到同样的错误。
  • 我遇到了同样的错误。你找到解决办法了吗?

标签: nuxt.js nuxt-content


【解决方案1】:

我也有这个,经过几个小时的谷歌搜索,我刚刚找到了这个页面:

https://www.fabiofranchino.com/blog/how-to-create-a-nuxt-based-blog-markdown-driven-from-scratch/

我已经安装了 frontmatter-markdown-loader 并在 nuxt.config.js 中包含了所需的配置 - 而且,瞧!不再出现控制台错误!

令人恼火,因为它似乎运行良好,尽管控制台出现错误...

【讨论】:

    猜你喜欢
    • 2020-10-23
    • 2020-04-27
    • 2022-07-06
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-26
    • 2020-01-10
    • 2021-08-03
    相关资源
    最近更新 更多