我已经安装了Vercel CLI来本地测试无服务器功能。
存储库如下:https://github.com/LuigiImVector/github-badge/tree/eda8e1954fc81d69142c461b89f32e9f7635f6f2
使用vercel dev
,我启动了本地主机服务器,但有一个问题。主页(index.html
)加载正确,但当我去http://localhost:3000/api
或http://localhost:3000/api/index.js
时出现错误。
影像误差
控制台显示的整个错误信息如下:
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 Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:782:11)
at Loader.resolve (internal/modules/esm/loader.js:88:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)
at Loader.import (internal/modules/esm/loader.js:176:28)
at importModuleDynamically (internal/modules/cjs/loader.js:1011:27)
at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
at getListener (C:UsersluigiAppDataRoamingnpmnode_modulesvercelnode_modules@vercelnodedistlauncher.js:66:24)
at C:UsersluigiAppDataRoamingnpmnode_modulesvercelnode_modules@vercelnodedistlauncher.js:77:5
at main (C:UsersluigiAppDataRoamingnpmnode_modulesvercelnode_modules@vercelnodedistdev-server.js:103:14)
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Error! Failed to complete request to /api/index.js: Error: read ECONNRESET
在网站上Vercel一切工作完美(https://github-badge-three.vercel.app/api?years=9),但在本地主机没有。
更新Vercel CLI:npm install -g vercel
(如果这不起作用试试npm install -g vercel@canary
)