Closed tinytini12 closed 1 month ago
Can you please give me a way to reproduce this? I know it should have happened but can't seem to encounter it.
You can use this repo: Repo updating django-vite-plugin package to its latest version, running npm run dev and opening http://localhost:5173/
I don't know why but I can not re create this. Please check the examples of this repo & create a pr with your problem.
You may check #69 and see if it fixes your problem.
I'm also having this problem; how can I install this branch in order to test?
Using pnpm
First clone this repo and cd into vite
directory. Then run:
pnpm run build
You can then install it in two ways:
Export a tarball and install from there
pnpm pack
And then cd into your project and install it:
pnpm install ../path/to/tarball
Install from directory: cd into your project and run
pnpm install ../path/to/cloned_repo/vite
Thanks! I was able to get the PR branch installed and it did seem to fix the problem!
Couldn't try this solution. This command throws and error in my computer pnpm run build
I have published the changes. Please check.
Fails for me:
[vite] Internal server error: ENOENT: no such file or directory, open 'C:\C:\Users\my-user\my-folder\projects\my-project\node_modules\django-vite-plugin\dist\esm\info.html'
Couldn't try this solution. This command throws and error in my computer
pnpm run build
Please try the same branch again. And let me know the error you are facing (if any)
Fails for me:
[vite] Internal server error: ENOENT: no such file or directory, open 'C:\C:\Users\my-user\my-folder\projects\my-project\node_modules\django-vite-plugin\dist\esm\info.html'
Its giving me two errors, the first one is Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'glob'
and once I install that, the second is the one above.
First pull #69 again And then:
Using pnpm First clone this repo and cd into
vite
directory. Then run:pnpm run build
You can then install it in two ways:
- Export a tarball and install from there
pnpm pack
And then cd into your project and install it:
pnpm install ../path/to/tarball
- Install from directory: cd into your project and run
pnpm install ../path/to/cloned_repo/vite
Did you follow these steps and still got no file error?
First pull #69 again And then:
Using pnpm First clone this repo and cd into
vite
directory. Then run:pnpm run build
You can then install it in two ways:
- Export a tarball and install from there
pnpm pack
And then cd into your project and install it:
pnpm install ../path/to/tarball
- Install from directory: cd into your project and run
pnpm install ../path/to/cloned_repo/vite
Did you follow these steps and still got no file error?
Yes, that's what I did
With type = module set in the package.json file please run the following code in terminal and send me the result.
function getAbsolutePathFromMetaUrl(path: string): string {
if (process.platform === 'win32' && path.startsWith('/')) {
return path.substring(1)
}
return path
}
console.log(getAbsolutePathFromMetaUrl(
typeof __dirname === 'undefined'
? // @ts-ignore
path.dirname(new URL(import.meta.url).pathname)
: __dirname,
))
Result
With type = module set in the package.json file please run the following code in terminal and send me the result.
function getAbsolutePathFromMetaUrl(path: string): string { if (process.platform === 'win32' && path.startsWith('/')) { return path.substring(1) } return path } console.log(getAbsolutePathFromMetaUrl( typeof __dirname === 'undefined' ? // @ts-ignore path.dirname(new URL(import.meta.url).pathname) : __dirname, ))
Result: C:\Users\my-user\my-folder\projects\my-project
Result: C:\Users\my-user\my-folder\projects\my-project
In that case, you are not supposed to get the error:
Fails for me: [vite] Internal server error: ENOENT: no such file or directory, open 'C:\C:\Users\my-user\my-folder\projects\my-project\node_modules\django-vite-plugin\dist\esm\info.html'
It uses the exact same code to resolve the path.
Please make sure you are in the correct branch. Reference: #70
Result: C:\Users\my-user\my-folder\projects\my-project
In that case, you are not supposed to get the error:
Fails for me: [vite] Internal server error: ENOENT: no such file or directory, open 'C:\C:\Users\my-user\my-folder\projects\my-project\node_modules\django-vite-plugin\dist\esm\info.html'
Check: a98c5c7
It uses the exact same code to resolve the path.
Please make sure you are in the correct branch. Reference: #70
You're right! in branch __dirname_fix it works
Thank you for the report. It's been updated, alhamdulillah. Please update to the latest version.
Thank you for the report. It's been updated, alhamdulillah. Please update to the latest version.
Thank you for all the work!
Hi! With last release and using as ESM, it's showing this error:
How to fix: https://flaviocopes.com/fix-dirname-not-defined-es-module-scope/