How to fix 'tsc: command not found'

孤街浪徒 提交于 2020-06-17 15:45:27

问题


I'm currently trying to install typescript on my machine for the first time. After installing node I run the following command:

sudo npm -g install typescript

This yields what appears to be a positive install message

/Users/mac/.npm-global/bin/tsc -> /Users/mac/.npm-global/lib/node_modules/typescript/bin/tsc /Users/mac/.npm-global/bin/tsserver -> /Users/mac/.npm-global/lib/node_modules/typescript/bin/tsserver + typescript@3.4.4 updated 1 package in 0.924s

After this, I check to see if the install was successful but running tsc --version and receive the following error:

tsc: command not found

From another thread I have tried:

restarting the terminal restarting the machine reinstalling nodejs + then run sudo npm install typescript -g

I have also tried updating my bash profile with the following line:

export PATH="$PATH:"/Users/mac/.npm-global/lib/node_modules/typescript/bin/tsc"";

I am not confident typescript resides in the location I listed. Is there a way to confirm?

Any help would be greatly appreciated.


回答1:


The following issue was fixed pretty easily. From your terminal open your bash profile:

open ~/.bash_profile

Edit your path to direct to the bin and not the executable (your path may vary see path after install):

/Users/mac/.npm-global/lib/node_modules/typescript/bin/

Save and close your file.

Reload your bash profile:

source ~/.bash_profile

Confirm all is working by checking the version:

tsc -v



来源:https://stackoverflow.com/questions/55767486/how-to-fix-tsc-command-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!