背景
Mac安装typeScript后,使用tsc命令报错zsh: command not found: tsc原因是zsh和bash的默认环境变量配置文件地址不一致。
解决
- 执行
cd ~/。 - 执行
touch .bash_profile创建.bash_profile - 执行
open .bash_profile打开.bash_profile - 在.bash_profile 文件中加入自己的环境变量配置文件地址
export PATH="/usr/local/lib/node_modules/typescript/bin/,并按command+s进行保存。 - 执行
source .bash_profile使配置生效。
结果
经过上述操作之后,再执行控制台就可以看到tsc命令有作用了。