我想安装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 10上,我通过添加%APPDATA%\npm到路径来解决这个问题

其他回答

我必须这样做:

npx tsc app.ts

以上这些对我都没用。

我也试过这个,

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. 

windows:

在命令提示符中用如下命令添加路径: = % %路径;路径C: \ \ \ npm的用户

在我的例子中,上面的路径没有为命令注册。

在运行的windows中,%userprofile%会给你路径C:\users\

检查你的npm版本 如果没有正确安装,请先安装 执行NPM install typescript -g 现在TSC <file_name>.ts 它会创建一个相应的.js文件。如< file_name > . js 现在尝试node <file_name>.js

对于mac用户,你不需要重启你的笔记本电脑或执行任何其他命令

使用brew install typescript