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

Error ERR_UNSUPPORTED_ESM_URL_SCHEME #112

Closed
madi86 opened this issue Dec 13, 2024 · 2 comments
Closed

Error ERR_UNSUPPORTED_ESM_URL_SCHEME #112

madi86 opened this issue Dec 13, 2024 · 2 comments

Comments

@madi86
Copy link

madi86 commented Dec 13, 2024

Hi guys,

Quite new to nextjs and saleor. I setup the saleor on docker and tried to run nimara locally but this is error I'm getting.

PS E:\saleor\nimara-ecommerce-main> pnpm -v
9.3.0
PS E:\saleor\nimara-ecommerce-main> node -v
v20.18.1

PS E:\saleor\nimara-ecommerce-main> pnpm i
apps/storefront |  WARN  The field "pnpm" was found in E:\saleor\nimara-ecommerce-main\apps\storefront/package.json. This will
not take effect. You should configure "pnpm" at the root of the workspace instead.
packages/ui |  WARN  The field "pnpm" was found in E:\saleor\nimara-ecommerce-main\packages\ui/package.json. This will not
take effect. You should configure "pnpm" at the root of the workspace instead.
Scope: all 11 workspace projects
Packages: +1871
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1871, reused 1862, downloaded 0, added 1871, done

devDependencies:

  • commitizen 4.3.0
  • dotenv-cli 7.4.2
  • eslint 8.57.0
  • eslint-config-custom 1.0.0 <- packages\eslint-config-custom
  • husky 9.1.6
  • lint-staged 15.2.7
  • turbo 2.1.2
  • vitest 2.0.5

. prepare$ husky
│ .git can't be found
└─ Done in 87ms
Done in 12.5s
PS E:\saleor\nimara-ecommerce-main> pnpm run dev:storefront

[email protected] dev:storefront E:\saleor\nimara-ecommerce-main
pnpm run dev --filter=storefront

[email protected] dev E:\saleor\nimara-ecommerce-main
dotenv -- turbo run dev "--filter=storefront"

╭──────────────────────────────────────────────────────────────────────────╮
│ │
│ Update available v2.1.2 ≫ v2.3.3 │
│ Changelog: https://github.com/vercel/turborepo/releases/tag/v2.3.3
│ Run "npx @turbo/codemod@latest update" to update │
│ │
│ Follow @turborepo for updates: https://x.com/turborepo
╰──────────────────────────────────────────────────────────────────────────╯
turbo 2.1.2

• Packages in scope: storefront
• Running dev in 1 packages
• Remote caching disabled
storefront:dev: cache bypass, force executing 1a4dd03ce3bb2ccb
storefront:dev:
storefront:dev: > [email protected] dev E:\saleor\nimara-ecommerce-main\apps\storefront
storefront:dev: > next dev --turbopack
storefront:dev:
storefront:dev: node:internal/modules/esm/load:249
storefront:dev: throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, schemes);
storefront:dev: ^
storefront:dev:
storefront:dev: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'e:'
storefront:dev: at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:249:11)
storefront:dev: at defaultLoad (node:internal/modules/esm/load:130:3)
storefront:dev: at ModuleLoader.load (node:internal/modules/esm/loader:555:13)
storefront:dev: at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:434:56)
storefront:dev: at new ModuleJob (node:internal/modules/esm/module_job:71:27)
storefront:dev: at #createModuleJob (node:internal/modules/esm/loader:447:17)
storefront:dev: at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:259:34)
storefront:dev: at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:17)
storefront:dev: at async ModuleLoader.import (node:internal/modules/esm/loader:472:23) {
storefront:dev: code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
storefront:dev: }
storefront:dev:
storefront:dev: Node.js v20.18.1
storefront:dev:  ELIFECYCLE  Command failed with exit code 1.
storefront:dev: ERROR: command finished with error: command (E:\saleor\nimara-ecommerce-main\apps\storefront) C:\Program Files\nodejs\pnpm.cmd run dev exited (1)
storefront#dev: command (E:\saleor\nimara-ecommerce-main\apps\storefront) C:\Program Files\nodejs\pnpm.cmd run dev exited (1)

Tasks: 0 successful, 1 total
Cached: 0 cached, 1 total
Time: 4.312s
Failed: storefront#dev

ERROR run failed: command exited (1)
 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.

@Fazalwahab12
Copy link

Issue:
The error occurs because the ts-import package fails to dynamically load the config.ts file on Windows due to path compatibility issues.

Solution:
Replace ts-import with require: Instead of using ts-import, directly use require to load the config.ts file in your next.config.ts:

typescript
Copy code
const { TRANSLATED_PATHNAME_PREFIXES } = require("./src/regions/config.ts");
Rename next.config.js to next.config.ts: To support TypeScript configurations, rename the configuration file to next.config.ts.

Steps:
Update the import in next.config.ts: Replace:

typescript
Copy code
import * as tsImport from "ts-import";
const { TRANSLATED_PATHNAME_PREFIXES } = await tsImport.load("./src/regions/config.ts");
With:

typescript
Copy code
const { TRANSLATED_PATHNAME_PREFIXES } = require("./src/regions/config.ts");
Rename your next.config.js file to next.config.ts.

Run the project:

bash
Copy code
pnpm run dev:storefront
This solution should resolve the Windows-specific issue and enable the project to run correctly

@karolkarolka
Copy link
Collaborator

I've just merged the fix with removing the legacy region config to the main branch so you shouldn't have any additional problems with installing the Nimara on Windows. The PR with fix is here and you can pull the latest changes from main branch.

Let me know if this resolved your issues and I will close the issue.

@madi86 madi86 closed this as completed Dec 18, 2024
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

3 participants