Bjö*_*rth 52 npm typescript tsc
当我tsc在终端中运行时(无论在哪里)我都会返回:
$ npx tsc --version
This is not the tsc command you are looking for
To get access to the TypeScript compiler, tsc, from the command line either:
- Use npm install typescript to first add TypeScript to your project before using npx
- Use yarn to avoid accidentally running code from un-installed packages
Run Code Online (Sandbox Code Playgroud)
据我所知,我没有在全球范围内安装 TypeScript,所以我期望它找不到tsc.
小智 70
我的问题是我安装了tsc软件包而不是正确的typescript. 来自https://www.npmjs.com/package/tsc:
用于
typescript访问tscCLI 命令。
修复方法是:
npm uninstall tsc
npm install -D typescript
Run Code Online (Sandbox Code Playgroud)
像这样的命令npx tsc --version仍然会运行,因为typescript提供了tsc可执行文件。
Vin*_*hah 26
在我的 Mac 上,这解决了这个问题:
npm uninstall -g typescript
npm install -g typescript
Run Code Online (Sandbox Code Playgroud)
当我闲逛试图开始时,我做了这样的事情:
npm install -g tsc #bad, don't do this
Run Code Online (Sandbox Code Playgroud)
这搞砸了我的安装。
没有什么可做的,因为这是一个非常简单的问题。转到已安装节点包的 VS Code 文件夹。例如,在我的系统中,它是:
C:\Users\vivekranjan\AppData\Roaming\npm
首先,您会注意到 tscServer 和 tsc 文件都没有创建。因此,首先删除所有 tsc 文件,然后转到 VS Code 并卸载 typeScript,如下所示:
npm uninstall typescript
Run Code Online (Sandbox Code Playgroud)
然后再次安装打字稿,如下所示:
npm install -g typescript
Run Code Online (Sandbox Code Playgroud)
tsc模块已弃用!如果您需要 tsc,您只需要typescript 模块!
通过以下方式安装打字稿模块:
npm install -D typescript
Run Code Online (Sandbox Code Playgroud)
小智 5
这为我解决了这个问题:
npm uninstall typescript
npm uninstall tsc #local tsc package
npm install typescript -g
Run Code Online (Sandbox Code Playgroud)
我错误地安装了旧的 typescript 编译器https://www.npmjs.com/package/tsc 。
运行where.exe tsc以找出 @siddharth 建议的我实际运行的内容让我发现了问题
| 归档时间: |
|
| 查看次数: |
41571 次 |
| 最近记录: |