当我想启动我的 vue 3 typescript 项目时出现以下错误:
ERROR Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:371:5)
at defaultResolve (node:internal/modules/esm/resolve:1016:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/cjs/loader:1041:29)
at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
at importModuleDynamically (node:vm:381:46)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at loadFileConfig (C:\Projects\backify-ui\documentation\node_modules\@vue\cli-service\lib\util\loadFileConfig.js:28:7)
自从我重命名我的 vue.config.js
后出现此错误至vue.config.mjs
.有趣的是,这个项目通过 gitpod.io 工作,但不能在 phpstorm 和 vscode 中工作。我的 vue.config.mjs:
import rehypeHighlight from "rehype-highlight";
export default {
chainWebpack: (config) => {
config.module
.rule("mdx")
.test(/\.mdx?$/)
.use("babel-loader")
.loader("babel-loader")
.options({ plugins: ["@vue/babel-plugin-jsx"] /* Other options… */ })
.end()
.use("@mdx-js/loader")
.loader("@mdx-js/loader")
.options({
jsx: true,
rehypePlugins: [rehypeHighlight] /* otherOptions… */,
})
.end();
},
};
最佳答案
我的问题是因为我的 Node.js 版本太低。升级到 Node.js 16 解决了这个问题。
关于javascript - 错误 [ERR_UNSUPPORTED_ESM_URL_SCHEME] : Only file and data URLs are supported by the default ESM loader - Vue 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69665780/