简体   繁体   English

-bash: tsc: 命令未找到

[英]-bash: tsc: command not found

I am using MAC and trying to install TypeScript.我正在使用 MAC 并尝试安装 TypeScript。 I install typescript using我安装打字稿使用

sudo npm install -g typescript须藤 npm install -g 打字稿

following is the result以下是结果

Password:
/Users/<myuserid>/node/bin/tsc -> /Users/<myuserid>/node/lib/node_modules/typescript/bin/tsc
/Users/<myuserid>/node/bin/tsserver -> /Users/<myuserid>/node/lib/node_modules/typescript/bin/tsserver
/Users/<myuserid>/node/lib
└── typescript@2.5.2 

Now when i try to use tsc i get error现在当我尝试使用 tsc 时出现错误

venu-mac:~ myuserid$ tsc -bash: tsc: command not found venu-mac:~ myuserid$

I do see tsc and tsserver exe files and following is tsc content我确实看到了 tsc 和 tsserver exe 文件,以下是 tsc 内容

$!/usr/bin/env node $!/usr/bin/env 节点
require('../lib/tsc.js')要求('../lib/tsc.js')

when I use following command from home it works当我在家使用以下命令时,它可以工作

~ myuserid$ node/bin/tsc -v ~ myuserid$ node/bin/tsc -v
Version 2.5.2版本 2.5.2

Same with Angular CLI installation.与 Angular CLI 安装相同。 I use the following command to install Angualr via CLI:我使用以下命令通过 CLI 安装 Angualr:

sudo npm install -g @angular/cli须藤 npm install -g @angular/cli

There are no errors or warnings while installing Angular CLI, but whenever I use ng commands I get the following:安装 Angular CLI 时没有错误或警告,但是每当我使用 ng 命令时,我都会得到以下信息:

-bash: ng: command not found -bash: ng: 命令未找到

I tried removing/uninstalling all typescript and ng then reinstalling, upgrade but it's been of no use...我尝试删除/卸载所有打字稿和 ng 然后重新安装、升级但它没有用......

Add ~/node/bin folder to the PATH variable~/node/bin文件夹添加到 PATH 变量

Advice: do not use that manuall nodejs install.建议:不要使用手动 nodejs 安装。 Have a look at nvm .看看nvm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM