import { performance } from ‘node:perf_hookSyntaxError: Cannot use import statement outside a module
新建TS项目运行时出现的错误import { performance } from 'node:perf_hookSyntaxError: Cannot use import statement outside a module
·
问题描述:在TS创建项目时
2,执行 npm init -y ;
“test”: “echo “Error: no test specified” && exit 1” 修改为 “dev”: “vite”
新建index.ts,然后在index.html导入index.ts
运行项目npm run dev
解决方法
nodejs不支持import语法,如果要支持,需要babel来支持
npm install --save babel-core
再启动项目,跑起来了
更多推荐
已为社区贡献7条内容
所有评论(0)