问题描述:在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
再启动项目,跑起来了
问题描述:在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
再启动项目,跑起来了