今天安装laravel/breeze套件时,运行npm run dev命令遇到报错,错误详细代码如下:
UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token '??='
at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8744) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
看了半天也不明白是啥意思,后来搜索了一下发现应该是nodejs版本过低的问题,于是升级了一下nodejs版本,从v14.17.6升级到v20.12.1。再次运行命令,成功执行,问题解决。


![Laravel 项目使用 npm run build 命令构建后,静态资源仍然为 http://[::1]:5173/@vite/client、http://[::1]:5173/resources/css/app.css、http://[::1]:5173/resources/js/app.js 的解决办法](https://www.02405.com/wp-content/uploads/2024/12/laravel-vite.webp)
![npm run dev:http://[::1]:5173 ERR_CONNECTION_REFUSED 错误的解决办法](https://www.02405.com/wp-content/uploads/2024/01/npm.webp)