今天启动vue项目的时候报了这错误:
D:\workspace\ui>npm run dev
> [email protected] dev D:\workspace\ui
> vite
file:///D:/workspace/ui/node_modules/vite/bin/vite.js:7
await import('source-map-support').then((r) => r.default.install())
^^^^^
SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:140:18)
at async link (internal/modules/esm/module_job.js:42:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\software\NodeJs\node_cache\_logs\2023-04-18T06_21_34_069Z-debug.log
查看是否安装成功:执行命令
vite -v
如果没有安装就执行安装命令。
安装vite:
打开命令窗口,执行命令
npm install vite -g
如果执行该命令报错:SyntaxError:Unexpected reserved word?,需要将nodejs升级至14及以上
先查看一下你本地的nodejs版本是多少:
node -v
下载高版本的nodejs:
https://nodejs.org/download/release/v14.18.3/
下载完成以后,再执行:
npm install
npm run dev
就可以了,亲测可用。