解决zsh: command not found: tsc问题
背景
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="$PATH:/Users/nonglaoshi/.npm-global/lib/node_modules/typescript/bin/"
,并按command+s进行保存。
注意:这里的 /Users/nonglaoshi/ 替换成你本地的环境所需要的地址(可通过命令 ls -a ~/.bash_profile获取) - 执行
source .bash_profile
使配置生效。
结果
经过上述操作之后,再执行控制台就可以看到tsc
命令有作用了。

下一篇:mac安装typescript教