声明:本站文章均为作者个人原创,图片均为实际截图。如有需要请收藏网站,禁止转载,谢谢配合!!!

1.安装typescript

npm install -g typescript

2.安装ts-node

npm install -g ts-node

3.初始化项目

生成package.json文件

npm init -y

4.初始化ts

生成tsconfig.json文件

tsc --init

5.package.json文件新增命令

"scripts": {
    "build": "tsc -w", // w监听变化
    "start": "ts-node ./src/index.ts",
    "test": "echo \"Error: no test specified\" && exit 1"
},

6.测试start运行命令

function say(p: string):string{
    return '八点博客' + p
}

console.log(say('6666'))

执行命令 npm run start

下载附件

7.测试build构建命令

执行命令 npm run build

在同级目录下生成 index.js 文件【文件对比如下】

下载附件

8.配置build输出目录

执行命令 npm run build

在dist目录下生成 index.js 文件

下载附件



点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论