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

./postcss.config.js: Error [ERRUNSUPPORTED_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 'c:'). Since version 14.1.2-canary.4 #63359

Closed
MrOxMasTer opened this issue Mar 16, 2024 · 10 comments · Fixed by #64386
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. Font (next/font) Related to Next.js Font Optimization. locked Module Resolution Module resolution (CJS / ESM, module resolving)

Comments

@MrOxMasTer
Copy link

Link to the code that reproduces this issue

https://github.com/MrOxMasTer/shopco

To Reproduce

  1. Try to build a package using "pnpm run build"

OR to check for another error:

  1. Upgrade to the latest version of next.js canary
  2. see that the project just doesn't start

Current vs. Expected behavior

complete project

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16320
  Available CPU cores: 6
Binaries:
  Node: 20.11.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.1.2-canary.3 // There is a newer canary version (14.2.0-canary.24) available, please upgrade!
  eslint-config-next: 14.1.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, CLI (create-next-app), Font optimization (next/font), Module resolution (CJS / ESM, module resolving)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

The first problem:
the project is not going to be built on version 14.1.2-canary.3. With "type": "module" in package.json

src\app\layout.tsx
An error occurred in next/font.

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\postcss.config.js from C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\node_modules.pnpm\next@14.1.2-canary.3_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\lib\find-config.js not supported.
Instead change the require of postcss.config.js in C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\node_modules.pnpm\next@14.1.2-canary.3_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\lib\find-config.js to a dynamic import() which is available in all CommonJS modules.
at mod.require (C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\node_modules.pnpm\next@14.1.2-canary.3_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\require-hook.js:65:28)
at findConfig (C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\node_modules.pnpm\next@14.1.2-canary.3_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\lib\find-config.js:58:20)
at async getPostCssPlugins (C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\node_modules.pnpm\next@14.1.2-canary.3_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\build\webpack\config\blocks\css\plugins.js:89:18)
at async C:\Users\Алексей\OneDrive\Рабочий стол\PetProjects\shopco\node_modules.pnpm\next@14.1.2-canary.3_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\build\webpack\config\blocks\css\index.js:124:36

image

@MrOxMasTer MrOxMasTer added the bug Issue was opened via the bug report template. label Mar 16, 2024
@github-actions github-actions bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Font (next/font) Related to Next.js Font Optimization. Module Resolution Module resolution (CJS / ESM, module resolving) labels Mar 16, 2024
@MrOxMasTer
Copy link
Author

The second problem:

Since version 14.1.2-canary.4, the project just won't even open in dev mode

./src/app/globals.css
Error evaluating Node.js code
Error: Failed to load external module C:\Users\Asus\Desktop\petProjects\shopco/./postcss.config.js: Error [ERRUNSUPPORTED_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 'c:'
at externalImport (/turbopack/[turbopack]/shared-node/base-externals-utils.ts:16:11) [C:\Users\Asus\Desktop\petProjects\shopco.next\chunks[output]__next_transform_ad1f0f.js:1318:15]
[at process.processTicksAndRejections (node:internal/process/task_queues:95:5)]
at async (postcss.config.js.loader.mjs:3:13) [C:\Users\Asus\Desktop\petProjects\shopco.next\chunks_0b8f1c._.js:11:13]

image
image

@MrOxMasTer
Copy link
Author

MrOxMasTer commented Mar 16, 2024

postcss/postcss#1931

The posts developers replied to me that these are your problems. You can find my post CSS config at the link

@MrOxMasTer
Copy link
Author

next.js config
image

ts.config
image

@MrOxMasTer
Copy link
Author

Just the latest version next.js
image

image

@MrOxMasTer MrOxMasTer changed the title Problems with PostCSS (ESM, URL-SCHEME and so on) Problems with PostCSS (ESM, URL-SCHEME and so on) Since version 14.1.2-canary.4 Mar 16, 2024
@MrOxMasTer
Copy link
Author

MrOxMasTer commented Mar 16, 2024

one of the 2 problems has been solved #63109

@MrOxMasTer MrOxMasTer changed the title Problems with PostCSS (ESM, URL-SCHEME and so on) Since version 14.1.2-canary.4 ./postcss.config.js: Error [ERRUNSUPPORTED_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 'c:'). Since version 14.1.2-canary.4 Mar 16, 2024
@EliasVal
Copy link

Having the same issue here, Canary (14.2.0-canary.26) seems to be working fine when disabling Turbopack on Windows.
Seems to be working fine in a Linux environment

@EliasVal
Copy link

Renaming postcss.config.js to postcss.config.cjs did the trick for me.

@MrOxMasTer
Copy link
Author

Renaming postcss.config.js to postcss.config.cjs did the trick for me.

It really helped, but it's weird. As if it needs to be fixed anyway.

@mike-kholin
Copy link

Renaming postcss.config.js to postcss.config.cjs did the trick for me.

It really helped, but it's weird. As if it needs to be fixed anyway.

----worked for me too

@huozhi huozhi closed this as completed in fbf9e12 Apr 12, 2024
ztanner pushed a commit that referenced this issue Apr 12, 2024
…ths (#64386)

### What?

Fixes #64371
Fixes #63359


Closes PACK-2946

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. Font (next/font) Related to Next.js Font Optimization. locked Module Resolution Module resolution (CJS / ESM, module resolving)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants