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

v9 fails within VSCode extension as import.meta.url is null #324

Open
tomqwpl opened this issue Oct 23, 2023 · 2 comments
Open

v9 fails within VSCode extension as import.meta.url is null #324

tomqwpl opened this issue Oct 23, 2023 · 2 comments

Comments

@tomqwpl
Copy link

tomqwpl commented Oct 23, 2023

I'm by no means a node expert, so I don't know whether import.meta.url being null is unexpected or not.
Trying to use this within a VSCode extension. The "import" of open fails, with an error on the line:

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Error is:

TypeError: The "path" argument must be of type string or an instance of URL. Received undefined
	at new NodeError (node:internal/errors:399:5)
	at fileURLToPath (node:internal/url:1491:11)

I don't know what is unusual about how vscode is loading modules. Not had any issues previously.

The v8.4.2 works in this regard. However, with that version you don't appear to be able to open "file:" urls without explicitly specifying that it should use a browser (using app: { name: apps.chrome} for example). However, that version doesn't have the ability to use the default browser.

@tomqwpl
Copy link
Author

tomqwpl commented Oct 23, 2023

Note, I should say that I'm testing on Windows. That is, "file:" urls not opening seems to be a function of Windows behaviour. If you use a Windows command line and just type "Start http://www.google.com" it works, but if you type "start file:///c%3a/somewhere" it doesn't. Note that "start file:///c:/somewhere" DOES work, however, that's not what you get when you URL encode a filename. Anyway, workaround is to explicitly specify "app: browser", but that doesn't work on version 8, "browser" was only introduced in version 9. The reference to "import.meta.url" in version 9 then fails when run inside VSCode for some reason.

@tomqwpl
Copy link
Author

tomqwpl commented Oct 23, 2023

Also, fragments don't work with file: URLs on Windows without using a specific app (so app: {name: apps.browser} for example).
So a URL such as file:///c:/somewhere#anchor1 appears to lose its fragment with you open it from a windows command line with Start, the address in the browser address bar is just "file:///c:/somewhere". Specifying app: {name: apps.browser} makes this work. All in all, the ability to use "apps.browser" is very convenient, hence why I'm keen to use v9 and not just use v8 as a workaround.

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

No branches or pull requests

1 participant