我是靠谱客的博主 心灵美时光,这篇文章主要介绍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
再启动项目,跑起来了

最后
以上就是心灵美时光最近收集整理的关于import { performance } from ‘node:perf_hookSyntaxError: Cannot use import statement outside a module的全部内容,更多相关import内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复