vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.91k stars 1.93k forks source link

Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'https:' Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'https:' #4007

Closed wspromise closed 1 day ago

wspromise commented 2 days ago

Describe the bug

build error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'https:' Error: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'https:' at new NodeError (node:internal/errors:405:5) at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:149:11) at defaultLoad (node:internal/modules/esm/load:99:3) at ModuleLoader.load (node:internal/modules/esm/loader:417:13) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:288:22) at new ModuleJob (node:internal/modules/esm/module_job:63:26) at #createModuleJob (node:internal/modules/esm/loader:312:17) at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:265:34) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:251:17) at async ModuleWrap. (node:internal/modules/esm/module_job:76:21)

Reproduction

,,,

Expected behavior

normal

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 9.1.3 - /usr/local/bin/pnpm
  npmPackages:
    vitepress: 1.2.2

Additional context

No response

Validations

wspromise commented 2 days ago

vitePress build failed

brc-dd commented 2 days ago

Please provide minimal reproducible example, preferably using https://vitepress.new

wspromise commented 1 day ago

Please provide minimal reproducible example, preferably using https://vitepress.new

https://stackblitz.com/edit/vite-nnfopi?file=docs%2F.vitepress%2Fconfig.ts

brc-dd commented 1 day ago

Looks like you haven't saved it. That link is just opening a fork of template.

wspromise commented 1 day ago

Looks like you haven't saved it. That link is just opening a fork of template.

https://stackblitz.com/edit/vite-qg6fun?file=docs%2F.vitepress%2Fconfig.ts,package.json

brc-dd commented 1 day ago
// 引入图标库
import 'https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_11053_364.62f38b08ba47924e13314f4c49fbf675.es5.js';

as the error says this is not supported in node.js.

If you want to add it to client, you need to add it to head - https://vitepress.dev/reference/site-config#head

wspromise commented 1 day ago

Thank you, you are right