Byte Ebi's Logo

Byte Ebi 🍤

每天一小口,蝦米變鯨魚

TypeScript 環境建置

設定 TypeScript 開發環境

Ray

建立 TypeScript 的開發環境
使用 NVM 安裝 Node.js 及 npm,安裝typescriptnodemonts-node等開發工具

NVM&NPM

Installing and Updating

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

or

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

安裝完之後使用指令確認 npm 版本

npm -v

開發環境

typescript

負責編譯 ts 成 js

nodemon

監視啟動指令時的資料夾下全部檔案,如果有檔案變動會自動重啟

ts-node

直接執行 ts 檔案

npx ts-node your-typescript-file.ts

初始化專案

首先要進入專案資料夾底下!

npm init -y # 初始化專案
npm install -D typescript nodemon ts-node # 安裝開發工具

調整package.json 中的 script/start

nodemon --exec ts-node index.ts

初始化 ts 設定

npx tsc --init

執行完會建立tsconfig.json檔案

最新文章

Category

Tag