kit: [vite-plugin-svelte-kit] Cannot read properties of undefined (reading 'paths') error during build

Describe the bug

When running npm run build this appears:

[vite-plugin-svelte-kit] Cannot read properties of undefined (reading 'paths') error during build

The cause is having a file with the same name and .js and .ts extensions in the same directory.

This took me three hours of my time to figure out, and I could not find a single answer anywhere online. I had to switch branches, stash, manually cut and paste hundreds of files, all because this error message was shown.

If we could instead show something along the lines of "Cannot have duplicate file names: {path/to/files}{filename} "

Reproduction

The cause is having a file with the same name and .js and .ts extensions in the same directory.

Logs

No response

System Info

Windows 10

Severity

annoyance

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 24 (2 by maintainers)

Commits related to this issue

Most upvoted comments

It seems like there a number of causes for this message, but basically it’s just hiding the details that were displayed properly extra-vite integration

As far as imports

import {someFunction} from 'someFile'

It gets that message if import someFunction is not exported in someFile It gets that message if someFile ( or the path ) is not correct or missing

Oddly it won’t throw an error on build when someFunction is not in someFile

There are other odd ones this error catches I have not been able to explain.

I believe I had a bad import path somewhere else that fixed it as well.

Check all your imports. The error message is very cryptic.

Everything was fine in dev env for me. Build command locally worked fine as well. Build on Netlify failed. Finally found an import statement starting with a capital letter but the actual file didn’t start with with a capital letter. Mac file system isn’t case sensitive which is why I suspect it worked fine locally. Thats my guess anyway. Fixed import and build is good to go.