Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'startsWith') #1315

Closed
VegasChickiChicki opened this issue Apr 5, 2024 · 5 comments

Comments

@VegasChickiChicki
Copy link

When i start vitest on nuxt project i see this:

TypeError: Cannot read properties of undefined (reading 'startsWith')
    at file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/image/dist/module.mjs:209:14
    at Array.map (<anonymous>)
    at setup (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/image/dist/module.mjs:208:39)
    at normalizedModule (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/kit/dist/index.mjs:2112:37)
    at async installModule (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/kit/dist/index.mjs:2415:95)
    at async initNuxt (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/nuxt/dist/index.mjs:4171:7)
    at async loadNuxt (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/nuxt/dist/index.mjs:4269:5)
    at async loadNuxt (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/kit/dist/index.mjs:2570:19)
    at async startNuxtAndGetViteConfig (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/test-utils/dist/config.mjs:40:16)
    at async getVitestConfigFromNuxt (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/test-utils/dist/config.mjs:83:15)
    at async file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/@nuxt/test-utils/dist/config.mjs:198:7
    at async loadConfigFromFile (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:68530:24)
    at async resolveConfig (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:68138:28)
    at async _createServer (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vite/dist/node/chunks/dep-whKeNLxG.js:64655:20)
    at async createViteServer (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vitest/dist/vendor/cac.RvTIWZBK.js:10951:18)
    at async createVitest (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vitest/dist/vendor/cac.RvTIWZBK.js:12219:18)
    at async startVitest (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vitest/dist/vendor/cac.RvTIWZBK.js:18772:15)
    at async start (file:///C:/Users/dodaa/WebstormProjects/site2/node_modules/vitest/dist/vendor/cac.RvTIWZBK.js:19563:17)
@Kheuval
Copy link

Kheuval commented Apr 20, 2024

Hello, I'm having the same issue.

My environment :
nuxt@3.11.2
@nuxt/image@1.2.0

@Kheuval
Copy link

Kheuval commented Apr 20, 2024

Hmm seems like I should have dig deeper ^^

The problem for me was that the image.domains in my nuxt.config.ts was set to an env variable and I didn't run the vitest run command with env variables.

@VegasChickiChicki maybe its the same for you ?

Copy link
Contributor

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a template for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/image/tree/main/example

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@VegasChickiChicki
Copy link
Author

Hmm seems like I should have dig deeper ^^

The problem for me was that the image.domains in my nuxt.config.ts was set to an env variable and I didn't run the vitest run command with env variables.

@VegasChickiChicki maybe its the same for you ?

This is help me, thanks!

@dukhevych
Copy link

in my case it failed here
if (!d.startsWith("http")) {

happens when domain is specified from variable that is undefined (for example env variable that doesn't exist)

probably it should throw some meaningful error in such cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants