vuejs / vitepress

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

The requested module 'node:dns' does not provide an export named 'setDefaultResultOrder' #1384

Closed imaxing closed 2 years ago

imaxing commented 2 years ago

Describe the bug

$ vitepress dev docs
file:///Users/mac/Desktop/vitepress-starter/node_modules/vitepress/dist/node/serve-38d4ddb1.js:1
import { setDefaultResultOrder } from 'node:dns';
         ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'node:dns' does not provide an export named 'setDefaultResultOrder'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:121:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:171:5)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
error Command failed with exit code 1.

Reproduction

This is the complete log data

iamgx ~/Desktop » mkdir vitepress-starter && cd vitepress-starter

iamgx Desktop/vitepress-starter » yarn init -y
yarn init v1.22.19
warning The yes flag has been set. This will automatically answer yes to all questions, which may have security implications.
success Saved package.json
✨  Done in 0.02s.
iamgx Desktop/vitepress-starter » yarn add --dev vitepress vue

yarn add v1.22.19
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error @vitejs/plugin-vue@3.1.0: The engine "node" is incompatible with this module. Expected version "^14.18.0 || >=16.0.0". Got "15.0.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
iamgx Desktop/vitepress-starter » nvm alias defult 16.0.0                                                           1 ↵
defult -> 16.0.0 (-> v16.0.0)
iamgx Desktop/vitepress-starter » nvm use 16.0.0         
Now using node v16.0.0 (npm v7.10.0)
iamgx Desktop/vitepress-starter » yarn add --dev vitepress vue

yarn add v1.22.19
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "vitepress > @docsearch/js > @docsearch/react > @algolia/autocomplete-preset-algolia@1.7.1" has unmet peer dependency "@algolia/client-search@^4.9.1".
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 48 new dependencies.
info Direct dependencies
├─ vitepress@1.0.0-alpha.15
└─ vue@3.2.39
info All dependencies
├─ @algolia/autocomplete-core@1.7.1
├─ @algolia/autocomplete-preset-algolia@1.7.1
├─ @algolia/cache-browser-local-storage@4.14.2
├─ @algolia/cache-in-memory@4.14.2
├─ @algolia/client-account@4.14.2
├─ @algolia/client-analytics@4.14.2
├─ @algolia/client-personalization@4.14.2
├─ @algolia/logger-console@4.14.2
├─ @algolia/requester-browser-xhr@4.14.2
├─ @algolia/requester-node-http@4.14.2
├─ @docsearch/css@3.2.1
├─ @docsearch/js@3.2.1
├─ @docsearch/react@3.2.1
├─ @types/web-bluetooth@0.0.15
├─ @vitejs/plugin-vue@3.1.0
├─ @vue/devtools-api@6.2.1
├─ @vue/reactivity-transform@3.2.39
├─ @vue/reactivity@3.2.39
├─ @vue/runtime-core@3.2.39
├─ @vueuse/core@9.2.0
├─ @vueuse/metadata@9.2.0
├─ @vueuse/shared@9.2.0
├─ algoliasearch@4.14.2
├─ body-scroll-lock@4.0.0-beta.0
├─ csstype@2.6.21
├─ esbuild-darwin-arm64@0.15.8
├─ esbuild@0.15.8
├─ function-bind@1.1.1
├─ has@1.0.3
├─ is-core-module@2.10.0
├─ jsonc-parser@3.2.0
├─ nanoid@3.3.4
├─ nprogress@0.2.0
├─ path-parse@1.0.7
├─ picocolors@1.0.0
├─ postcss@8.4.16
├─ preact@10.11.0
├─ resolve@1.22.1
├─ rollup@2.78.1
├─ shiki@0.11.1
├─ source-map-js@1.0.2
├─ sourcemap-codec@1.4.8
├─ supports-preserve-symlinks-flag@1.0.0
├─ vite@3.1.3
├─ vitepress@1.0.0-alpha.15
├─ vscode-oniguruma@1.6.2
├─ vscode-textmate@6.0.0
└─ vue@3.2.39
✨  Done in 2.66s.
iamgx Desktop/vitepress-starter » mkdir docs && echo '# Hello VitePress' > docs/index.md

iamgx Desktop/vitepress-starter » vim package.json
iamgx Desktop/vitepress-starter » yarn docs:dev

yarn run v1.22.19
$ vitepress dev docs
file:///Users/mac/Desktop/vitepress-starter/node_modules/vitepress/dist/node/serve-38d4ddb1.js:1
import { setDefaultResultOrder } from 'node:dns';
         ^^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'node:dns' does not provide an export named 'setDefaultResultOrder'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:121:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:171:5)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

hope the script can works

System Info

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 113.11 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.0.0 - ~/.nvm/versions/node/v16.0.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 7.10.0 - ~/.nvm/versions/node/v16.0.0/bin/npm
  Browsers:
    Chrome: 105.0.5195.125
    Safari: 15.6.1
  npmPackages:
    vitepress: ^1.0.0-alpha.15 => 1.0.0-alpha.15

Additional context

No response

Validations

brc-dd commented 2 years ago

Try using the latest version of Node 16 instead.

imaxing commented 2 years ago

Try using the latest version of Node 16 instead.

it works, thanks!

Zhengqbbb commented 2 years ago

Try using the latest version of Node 16 instead.

Maybe package.json need add engines.node to check and warn user's node version ?