vite + vu3 + ts 项目,npm run build 报错

新建了vite 项目,build的时候报错: 

npm ERR! [email protected] build: `vue-tsc && vite build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

> [email protected] build E:\learn\demo1\demo1
> vue-tsc && vite build

E:\learn\demo1\demo1\node_modules\@vue\language-core\out\generators\template.js:261
                        tagOffsetsMap[tag] ??= [];
                                           ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object. (E:\learn\demo1\demo1\node_modules\@vue\language-core\out\index.js:30:14)    
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vue-tsc && vite build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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:

 这个报错是 node 版本问题,一查 版本是 14.21.1 的,换成 16.0.0 的 问题解决

这里更换 node 版本 强烈建议 使用 NVM 工具,切换 node 版本贼快,再也不用像之前那样 卸载node重装啦

你可能感兴趣的:(npm,前端,node.js)