intlify / nuxt3

Nuxt 3 Module for vue-i18n-next
MIT License
202 stars 19 forks source link

NuxtI18n not starting #5

Open jbmolle opened 3 years ago

jbmolle commented 3 years ago

Hi, I've just installed "@intlify/nuxt3": "^0.1.2" with "nuxt3": "latest" and added the buildModules: ["@intlify/nuxt3"]. When I start Nuxt with npm run dev, I got an error:

(node:10922) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. Server Side Rendering Error: ./node_modules/@intlify/shared/dist/shared.esm-bundler.js:192 export { assign, createEmitter, escapeHtml, format, friendlyJSONstringify, generateCodeFrame, generateFormatCacheKey, getGlobalThis, hasOwn, inBrowser, isArray, isBoolean, isDate, isEmptyObject, isFunction, isNumber, isObject, isPlainObject, isPromise, isRegExp, isString, isSymbol, makeSymbol, mark, measure, objectToString, toDisplayString, toTypeString, warn };

I have the same problem when I copy the plugin code in plugin folder of nuxt and use vue-i18n-next

Thanks JB

chz commented 3 years ago

nuxt.config.js:

import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
  components: true,
  buildModules: [
    ['@pinia/nuxt', { disableVuex: true }],
    '@intlify/nuxt3'
  ],
  intlify: {
    vueI18n: {
      // You can setting same `createI18n` options here !
      locale: 'en',
      messages: {
        en: {
          hello: 'Hello'
        },
        ja: {
          hello: 'こんにちは'
        }
      }
    }
  }
})

yarn dev:

ERROR  Cannot start nuxt:  Invalid URL: undefined                                                                                                                                                    

  at new NodeError (internal/errors.js:322:7)
  at onParseError (internal/url.js:270:9)
  at new URL (internal/url.js:346:5)
  at node_modules/@intlify/nuxt3/dist/module.js:212:35
  at g (node_modules/jiti/dist/jiti.js:1:55512)
  at requireModule (node_modules/@nuxt/kit/dist/index.mjs:85:26)
  at installModule (node_modules/@nuxt/kit/dist/index.mjs:1176:15)
  at initNuxt (node_modules/nuxt3/dist/index.mjs:817:11)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6755:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6786:5)
kazupon commented 3 years ago

I'm fixing now. please wait

jbmolle commented 3 years ago

Thanks, I've just pulled the repo and it's working!

chz commented 3 years ago

nuxt.config.js:

import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
  components: true,
  buildModules: [
    ['@pinia/nuxt', { disableVuex: true }],
    '@intlify/nuxt3'
  ],
  intlify: {
    vueI18n: {
      // You can setting same `createI18n` options here !
      locale: 'en',
      messages: {
        en: {
          hello: 'Hello'
        },
        ja: {
          hello: 'こんにちは'
        }
      }
    }
  }
})

yarn dev:

ERROR  Cannot start nuxt:  Invalid URL: undefined                                                                                                                                                    

  at new NodeError (internal/errors.js:322:7)
  at onParseError (internal/url.js:270:9)
  at new URL (internal/url.js:346:5)
  at node_modules/@intlify/nuxt3/dist/module.js:212:35
  at g (node_modules/jiti/dist/jiti.js:1:55512)
  at requireModule (node_modules/@nuxt/kit/dist/index.mjs:85:26)
  at installModule (node_modules/@nuxt/kit/dist/index.mjs:1176:15)
  at initNuxt (node_modules/nuxt3/dist/index.mjs:817:11)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6755:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6786:5)

@kazupon same problem. I can't start app

jbmolle commented 3 years ago

@chz the new version is not on npm yet. Right now, you need to pull the repo and build it. Then in your package.json you reference the lib with "@intlify/nuxt3": "file:xxx/packages/nuxt3" xxx is the location of this repo on your computer

@kazupon can you put 1.0.4 on npm, please? Thanks, JB

tanc commented 3 years ago

@kazupon can you please release a new version to make testing a bit easier?

kazupon commented 3 years ago

I've just released v0.1.4 https://github.com/intlify/nuxt3/pull/8 Please try it!

However, nuxt3 is always updating. Maybe, this module might not work. :p