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/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. 代表成功

posted @ 2020-10-13 20:28  热爱前端的17号诶  阅读(859)  评论(0编辑  收藏  举报