当我使用@nuxtjs/prismic和nuxt-i18n时,会收到一条错误消息。
错误信息:
错误ENOENT:没有这样的文件或目录,打开'C:\wamp64\www\nuxt-test\prismic.nuxt\prismic\pages\preview.vue
package.json:
{
"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:
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
知道为什么吗?
谢谢你亚历克斯
发布于 2020-03-30 11:26:12
在i18n部分的nuxt.config.js中,将parsePages设置为false。
示例:
i18n: {
locales: ["nl", "en"],
defaultLocale: "nl",
vueI18n: {
fallbackLocale: "nl",
messages: locales
},
parsePages: false
},来自文档:
// By default, custom routes are extracted from page files using babel parser,
// set this to false to disable this
parsePages: true,https://stackoverflow.com/questions/59843019
复制相似问题