Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前端启动运行时报vite.config.js不存在模块node:url #2

Closed
HuiKwen opened this issue Jul 13, 2023 · 1 comment
Closed

前端启动运行时报vite.config.js不存在模块node:url #2

HuiKwen opened this issue Jul 13, 2023 · 1 comment

Comments

@HuiKwen
Copy link

HuiKwen commented Jul 13, 2023

前端进行install后,直接通过 'npm run dev' 命令进行启动运行。但发现报错。(本人使用的node版本是:v14.17.0)

`
failed to load config from E:\Study\WeBlog\weblog-vue3\vite.config.js
error when starting dev server:
Error: Cannot find module 'node:url'
Require stack:

  • E:\Study\WeBlog\weblog-vue3\vite.config.js
  • E:\Study\WeBlog\weblog-vue3\node_modules\vite\dist\node\chunks\dep-8609dc5d.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    `

即时根据网上搜索的内容将import 中内容改成以下,则寻找不到的模块变成是path

import { fileURLToPath, URL } from 'url'

`
Error: Cannot find module 'node:path'
Require stack:

  • E:\Study\WeBlog\weblog-vue3\node_modules\vite\dist\node-cjs\publicUtils.cjs
  • E:\Study\WeBlog\weblog-vue3\node_modules\vite\index.cjs
  • E:\Study\WeBlog\weblog-vue3\vite.config.js

`

想请教一下楼主这个问题您有遇到过么?

@weiwosuoai
Copy link
Owner

我的 node 版本:18.15.0, 学习 vue 3 官方要求最低版本 16.0+, 建议升级一下再试试

@HuiKwen HuiKwen closed this as completed Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants