question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read properties of undefined (reading 'VITE_LARAVEL_VUE_I18N_HAS_PHP')

See original GitHub issue
  • laravel-vue-i18n - 2.1.1
  • vite - 2.9.9
  • vuejs 3.2.25
  • node 16.16.0
  • without laravel
// .env

VITE_LARAVEL_VUE_I18N_HAS_PHP=false
// src/main.ts

import { createApp } from 'vue'
import { i18nVue } from 'laravel-vue-i18n'
import i18nOptions from '@/utils/lang'

import pinia from '@/utils/pinia'

createApp(App)
    .use(i18nVue, i18nOptions(pinia))
// src/utils/lang

import { Pinia } from 'pinia'
import { useSettingsStore } from '@/stores/settings'

export default (pinia: Pinia) => {
    const lang = useSettingsStore(pinia).locale

    const resolve = async (lang: string) => {
        const files = import.meta.glob('../../lang/*.json')

        return await files[`../../lang/${ lang }.json`]()
    }

    return { lang, resolve }
}

image

Result: not working

image

If we add output to the console, we see that the files are loaded:

const resolve = async (lang: string) => {
    const files = import.meta.glob('../../lang/*.json')

    console.log(files)
    console.log(
        import.meta.env.VITE_API_URL,
        import.meta.env.VITE_LARAVEL_VUE_I18N_HAS_PHP
    )

    return await files[`../../lang/${ lang }.json`]()
}

image

image

Without the VITE_LARAVEL_VUE_I18N_HAS_PHP key, I also get the error:

image

Version 1.4.4 worked perfectly.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
xiCO2kcommented, Jul 24, 2022

Awesome, will tag it

1reaction
xiCO2kcommented, Jul 23, 2022

Thanks for the PR, can you try again, and let me know?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "Cannot read properties of undefined ... - Stack Overflow
I am creating library for card using components, creating 3 components. card-body; card-header; card-footer when I try to build the library, it ...
Read more >
Why is the error "Cannot read properties of undefined (reading ...
I'm building a LWC to be used as a flow screen component. In the LWC, I allow the border color of the component...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
TypeError: Cannot read properties of undefined (reading 'post ...
Unfortunatelly, I receive the type error as follows: TypeError: Cannot read properties of undefined (reading 'post') I tried wit...
Read more >
Cannot read properties of undefined (reading 'nameMap')
As soon as I set the value of one of the variable via ATF, I am getting below error: Cannot read properties of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found