安裝
npm install -g typescript
初始化ts.config問題
mac 在實行tsc --init
時,報bash: tsc: command not found
-
解決辦法:
- 輸入
cd ~/
進入當前用戶的home目錄 - 打開並編輯bash_profile 執行命令
open .bash_profile
,若沒有的話,則touch .bash_profile
創建 - 在 bash_profile 文件中
-
有兩種方式:
*export PATH=/usr/local/bin:$PATH
export M3_HOME=/usr/local/Cellar/maven@3.3/3.3.9
export PATH=$PATH:$M3_HOME/bin
這個是后面添加
export PATH=你安裝的ts的目錄,指向bin的
,在安裝時終端會提示,比如/usr/local/Cellar/node/8.0.0_1/lib/node_modules/typescript/bin/
*PATH=$PATH:/usr/local/mysql/bin:/usr/local/Cellar/node/8.0.0_1/lib/node_modules/typescript/bin/
這個是在后面添加
:你安裝的ts的目錄,指向bin的
,只要前面有路徑,直接用:隔開
4. 然后保存,關閉
5. 運行source .bash_profile
6. 再運行tsc --init
,出現message TS6071: Successfully created a tsconfig.json file.
代表成功 - 輸入