首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ENOENT:没有这样的文件或目录preview.vue、prismic模块和nuxt-i18n

ENOENT:没有这样的文件或目录preview.vue、prismic模块和nuxt-i18n
EN

Stack Overflow用户
提问于 2020-01-21 14:15:14
回答 1查看 2.9K关注 0票数 3

当我使用@nuxtjs/prismic和nuxt-i18n时,会收到一条错误消息。

错误信息:

错误ENOENT:没有这样的文件或目录,打开'C:\wamp64\www\nuxt-test\prismic.nuxt\prismic\pages\preview.vue

package.json

代码语言:javascript
复制
{
  "name": "prismic-nuxtjs",
  "version": "1.0.0",
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/dotenv": "^1.4.0",
    "@nuxtjs/prismic": "^1.0.1",
    "@nuxtjs/pwa": "^3.0.0-0",
    "nuxt": "^2.0.0",
    "nuxt-i18n": "^6.5.0"
  },
  "devDependencies": {
    "@nuxtjs/tailwindcss": "^1.0.0",
    "@nuxtjs/eslint-config": "^1.0.1",
    "@nuxtjs/eslint-module": "^1.0.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^6.1.0",
    "eslint-plugin-nuxt": ">=0.4.2",
    "@nuxtjs/stylelint-module": "^3.1.0",
    "stylelint": "^10.1.0",
    "stylelint-config-recommended": "^3.0.0"
  }
}

nuxt.config.js

代码语言:javascript
复制
export default {
  mode: 'universal',
  /*
  ** Headers of the page
  */
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
  ],
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: [
    // Doc: https://github.com/nuxt-community/eslint-module
    '@nuxtjs/eslint-module',
    // Doc: https://github.com/nuxt-community/stylelint-module
    '@nuxtjs/stylelint-module',
    // Doc: https://github.com/nuxt-community/nuxt-tailwindcss
    '@nuxtjs/tailwindcss'
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    // Doc: https://github.com/nuxt-community/dotenv-module
    '@nuxtjs/dotenv',
    // Doc : https://prismic-nuxt.js.org
    '@nuxtjs/prismic',
    // Doc : https://nuxt-community.github.io/nuxt-i18n/
    ['nuxt-i18n', {
      lazy: true,
      locales: [
        {
          name: 'French',
          code: 'fr',
          iso: 'fr-FR',
          file: 'fr-FR.js'
        },
        {
          name: 'English',
          code: 'en',
          iso: 'en-US',
          file: 'en-US.js'
        },
      ],
      langDir: 'lang/',
      defaultLocale: 'fr'
    }]
  ],

  /*
  ** Prismic configuration
  */
  prismic: {
    endpoint: 'https://nuxt-prismic-20.cdn.prismic.io/api/v2'
  },

  /*
  ** Axios module configuration
  ** See https://axios.nuxtjs.org/options
  */
  axios: {
  },
  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend (config, ctx) {
    }
  }
}

在根目录下,我有一个包含两个文件的文件夹/lang/fr-FR.js/en-US.js

为了解决这个问题,我创建了一个预览文件app/prismic/pages/preview.vue,但是我得到了相同的消息: ERROR ENOENT:没有这样的文件或目录,打开app/prismic/pages/preview.vue

知道为什么吗?

谢谢你亚历克斯

EN

回答 1

Stack Overflow用户

发布于 2020-03-30 11:26:12

在i18n部分的nuxt.config.js中,将parsePages设置为false。

示例:

代码语言:javascript
复制
i18n: {
    locales: ["nl", "en"],
    defaultLocale: "nl",
    vueI18n: {
      fallbackLocale: "nl",
      messages: locales
    },
    parsePages: false
  },

来自文档

代码语言:javascript
复制
// By default, custom routes are extracted from page files using babel parser,
// set this to false to disable this
parsePages: true,
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59843019

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档