TypeScript学习笔记--初始化

安装

npm install -g typescript

初始化ts.config问题

mac 在实行tsc --init时,报bash: tsc: command not found

  • 解决办法:

    1. 输入cd ~/ 进入当前用户的home目录
    2. 打开并编辑bash_profile 执行命令
      open .bash_profile,若没有的话,则touch .bash_profile创建
    3. 在 bash_profile 文件中
    • 有两种方式:
      *

      export PATH=/usr/local/bin:$PATH
      export M3_HOME=/usr/local/Cellar/[email protected]/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. 代表成功

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章