lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat
MIT License
1.33k stars 70 forks source link

Error initializing project 初始化项目出错 #42

Closed NoiseFan closed 1 year ago

NoiseFan commented 1 year ago

After initializing the project, the following error is reported when executing npm run dev

在初始化项目之后,执行 npm run dev的时候报如下错误

` shell npm create monkey

cd xxx

npm install

npm run dev `

xxx_plugin@0.0.0 dev vite

failed to load config from /Users/xxx/Code/xxx_plugin/vite.config.ts error when starting dev server: SyntaxError: Unexpected token '||=' at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)

lisonge commented 1 year ago

||= 语法最低支持为 node15 ,推荐node16

lisonge commented 1 year ago

是因为 tsup 的 target 配置被 tsconfig.json 覆盖为 esnext

导致缺省值 target: 'node14' 失效,从而没有执行语法转译

lisonge commented 1 year ago

fied on v2.11.1

修复了在 node14 上的语法报错,再次运行相同的命令将不会报错

注意: node 版本与 vite 要求一致 ^14.18.0||>=16

NoiseFan commented 1 year ago

非常感谢,已经解决