bug:failed to load config from D:\work\xxxxxxxxx\vite.config.ts SyntaxError: Unexpected token ‘.‘

vue3,vite项目,执行yarn dev,报错:

bug:failed to load config from D:\work\xxxxxxxxx\vite.config.ts SyntaxError: Unexpected token ‘.‘_第1张图片
SyntaxError: Unexpected token ‘.’
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (D:\work\xxxxxxxxx\node_modules\unplugin-icons\dist\chunk-IH4E764S.js:73:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)
error Command failed with exit code 1.info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

原因

我使用的是node12.21.0,版本太低,node无法识别此语法。

解决方案:

检查node版本,将node版本升级到16+。
bug:failed to load config from D:\work\xxxxxxxxx\vite.config.ts SyntaxError: Unexpected token ‘.‘_第2张图片
bug:failed to load config from D:\work\xxxxxxxxx\vite.config.ts SyntaxError: Unexpected token ‘.‘_第3张图片
成功。

你可能感兴趣的:(bug)