我想安装typescript,所以我使用了下面的命令:

npm install -g typescript 

和测试TSC——版本,但它只是显示' TSC命令未找到'。我尝试了stackoverflow, github和其他网站中建议的许多方法。但这并不奏效。我怎么知道typescript被安装和它在哪里。

我的操作系统是Unix, OS X El Capitan 10.11.6 节点版本为4.4.3, NPM的版本是3.10.5


当前回答

对于windows和yarn用户,请尝试yarn tsc——init

其他回答

以上没有一个能解决我的问题。 事实是,我的项目没有安装类型脚本。 但是我在本地运行了npm install -g typescript。所以我没有注意到typescript节点依赖不在我的包json。

当我把它推到服务器端,并运行npm install,然后npx tsc,我得到一个tsc not found。事实上,远程服务器没有安装typescript。这是隐藏的,因为我的本地全局typescript安装。

全局安装TypeScript包对我来说很有效。

npm install typescript -g

我发现Mac很容易修复。只需运行这些命令:

sudo npm install -g concurrently
sudo npm install -g lite-server
sudo npm install -g typescript

对我来说,除了这个,什么都没用。

以上这些对我都没用。

我也试过这个,

yum install typescript 

能够千方百计地编译如下。不推荐,只是一个变通办法。

只要使用npm在本地安装,就像npm install typescript一样,并在node_module文件夹中验证,如果已经下载。然后跑,

./node_modules/typescript/bin/tsc  --help
./node_modules/typescript/bin/tsc  //this line actually runs and compile and generate the compiled file. 

Use:

npm rebuild typescript

这将在您的机器上重新构建tsc链接。