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

export posix and win32 cannot be destructured #192

Closed
xeho91 opened this issue Dec 29, 2024 · 0 comments · Fixed by #193
Closed

export posix and win32 cannot be destructured #192

xeho91 opened this issue Dec 29, 2024 · 0 comments · Fixed by #193
Labels
bug Something isn't working

Comments

@xeho91
Copy link
Contributor

xeho91 commented Dec 29, 2024

Environment

  • pathe@1.1.2
  • Node.js v22.12.0
  • macOS Sequoia v15.2

Reproduction

I believe the error message below is descriptive enough. We're using pathe inside the SvelteKit project as resolve.alias for "path" or "node:path", like so:

// vite.config.js
export default defineConfig((env) => {
	return {
		resolve: {
			alias: {
				path: env.isSsrBuild ? "node:path" : "pathe",
				"node:path": env.isSsrBuild ? "node:path" : "pathe",
			},
		},
	};
});

This is set this way because some of the imported dependencies are using "node:path", which cannot be used in browser for example.

Describe the bug

The value win32 cannot be destructured/imported from this package. The error occurs during Vite build process.

Additional context

Node.js documentation

Logs

import path$1, { join, dirname, win32, resolve as resolve$2 } from "pathe";
                                ^^^^^
SyntaxError: The requested module 'pathe' does not provide an export named 'win32'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:263:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
    at async Promise.all (index 8
import path$2, { resolve as resolve$3, join as join$1, win32, posix, isAbsolute } from "pathe";
                                                              ^^^^^
SyntaxError: The requested module 'pathe' does not provide an export named 'posix'
@xeho91 xeho91 added the bug Something isn't working label Dec 29, 2024
@xeho91 xeho91 changed the title export win32 cannot be destructured export posix and win32 cannot be destructured Dec 30, 2024
@pi0 pi0 closed this as completed in #193 Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant