为什么我在运行 NextJS 应用程序时收到此 ERR_UNSUPPORTED_ESM_URL_SCHEME 错误? [已关闭]

问题描述 投票:0回答:1

我收到此错误:

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

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 'c:'
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:236:11)
    at defaultLoad (node:internal/modules/esm/load:128:3)
    at ModuleLoader.load (node:internal/modules/esm/loader:409:13)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:56)
    at new ModuleJob (node:internal/modules/esm/module_job:65:26)
    at #createModuleJob (node:internal/modules/esm/loader:303:17)
    at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:260:34)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:241:17)
    at async ModuleLoader.import (node:internal/modules/esm/loader:328:23)

我尝试过这个命令:

npm run dev

我期待我的应用程序成功运行并显示 vercal 的默认 NextJS 页面。

web development-environment next.js14
1个回答
0
投票

Next.js 14.2 中的此错误与 Windows 上的 ESM 导入有关。

此问题已修复

问题

解决方法(已过时)

postcss.config.mjs
重命名为
postcss.config.cjs

然后将导出更改为:

export default config;

至:

module.exports = config;

作为临时解决方案,这应该可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.