这不是您要查找的 tsc 命令

This is not the tsc command you are looking for

当我在终端中 运行 tsc 时(无论在哪里)我得到返回:

This is not the tsc command you are looking for

据我所知,我没有全局安装 TypeScript,所以我期待的是它找不到 tsc

我错误地安装了旧的打字稿编译器https://www.npmjs.com/package/tsc

运行 where.exe tsc 找出我实际上是什么 运行 @siddharth 建议让我找到了问题

我的问题是我安装了 tsc 包而不是正确的打字稿。


修复方法是:

npm卸载tsc

tsc 模块已弃用!你只需要 typescript module,如果你需要 tsc!!!

秒。 https://www.npmjs.com/package/tsc

没有什么可做的,因为这是一个非常简单的问题。 转到安装节点包的 vs 代码文件夹。 比如在我的系统中是:

C:\Users\vivek\AppData\Roaming\npm

首先您会注意到 tscServer 和 tsc 文件都没有创建。所以先删除所有的tsc文件,然后去vs code卸载typeScript,像这样:

npm uninstall typescript

然后像这样再次安装打字稿:

npm install -g typescript

尝试使用 chocolatey manager 进行 typescript 安装 https://community.chocolatey.org/packages/typescript

choco install typescript

在我的 Mac 上,这修复了它:

npm uninstall -g typescript
npm install -g typescript

当我开始胡思乱想的时候,我做了这样的事情:

npm install -g tsc   #bad, don't do this

它搞砸了我的安装。

如果使用 Volta 或类似的版本管理器,你可以做到

npm remove -g typescript tic
pnpm remove -g typescript (if using pnpm)

并使用您选择的节点包管理器(全局)再次安装它!