我在我的 mac 上使用 npm 全局安装了类型脚本,但它不工作

I installed type script globally with npm on my mac and it not working

我尝试使用命令 npm install typescript -g 在我的 mac 上全局安装 TS 之前也用“sudo”试过这个,它看起来像工作但是当我试图在终端中查找我的 tsc 版本时,我得到这个错误 zsh: command not found: tsc.

在 mac 上,而不是 NPM,安装打字稿:

brew install typescript

(另外,如果你想让 npm i -g typescript 工作,请尝试 将全局安装的包添加到 PATH)

还要确保为您的 IDE 安装正确的 ts 扩展。