首页 - 服务器知识

解决zsh: command not found: tsc问题

背景

Mac安装typeScript后,使用tsc命令报错zsh: command not found: tsc原因是zsh和bash的默认环境变量配置文件地址不一致。

解决

  1. 执行cd ~/
  2. 执行touch .bash_profile 创建.bash_profile
  3. 执行open .bash_profile 打开.bash_profile
  4. 在.bash_profile 文件中加入自己的环境变量配置文件地址
    export PATH="$PATH:/Users/nonglaoshi/.npm-global/lib/node_modules/typescript/bin/",并按command+s进行保存。
    注意:这里的  /Users/nonglaoshi/ 替换成你本地的环境所需要的地址(可通过命令 ls -a ~/.bash_profile获取)
  5. 执行source .bash_profile 使配置生效。

结果

经过上述操作之后,再执行控制台就可以看到tsc命令有作用了。