-
Notifications
You must be signed in to change notification settings - Fork 16
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
__dirname is not defined #67
Comments
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 pnpm run build You can then install it in two ways:
pnpm pack And then cd into your project and install it: pnpm install ../path/to/tarball
|
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 |
I have published the changes. Please check. |
Fails for me: |
Please try the same branch again. And let me know the error you are facing (if any) |
Its giving me two errors, the first one is |
First pull #69 again
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
Result: C:\Users\my-user\my-folder\projects\my-project |
In that case, you are not supposed to get the error:
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 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/
The text was updated successfully, but these errors were encountered: