. Advertisement .
..3..
. Advertisement .
..4..
In this post, you will learn how to troubleshoot the “Tsc command not found Typescript error” quickly and effectively. Let’s get started with the possible solutions below.
When does “Tsc Command Not Found Typescript Error” occur?
The “Tsc Command Not Found Typescript Error” will happen when you compile the TypeScript and start running the Tsc command to check a version of Tsc.
At this moment, the error will appear on your screen below:
Tsc Command Not Found Typescript Error
The main cause of this problem is that you do not install the typescript package properly.
How to solve this problem?
Solution 1: Run the command to install Typescript
All you need to do is to install Typescript, and check a version of Tsc.
npm install typescript@latest -g
# create json file
tsc --init
# check the version
tsc --version
If it’s failed, you have to try using ‘Sudo’.
# Try using sudo
sudo npm install typescript@latest -g
tsc --init
tsc --version
Conversely, if this issue can not be tackled, reboot your terminal. Then, run your program below.
npm config get prefix
You will know a path where ‘npm’ puts the installed packages. As usual, the packages are in the ‘bin’ directory with a defined path.
For instance, when you use Windows, the result of the ‘npm config get prefix’ command might be like this:
‘C:\Users\Your_User_Name\AppData\Roaming\npm’.
As for macOS, run a command to update the path below.
# the path fits with npm
export PATH=/usr/local/share/npm/bin:$PATH
The result is added from the command to the ‘.bashrc’ file in a Linux platform.
# check and update the path
export PATH="/usr/local/share/npm/bin:$PATH"
Finally, run your command, and the error will be troubleshot entirely.
Solution 2: Reinstall Nodejs and run npm install typescript -g
If this might not work, attempt to reinstall Node.js and install Typescript.
npm install typescript@latest -g
tsc --init
tsc --version
If the installation fails, prefixing with ‘Sudo.’
# Try using Sudo
sudo npm install typescript@latest -g
tsc --init
tsc --version
That’s it. We believe you can solve this error completely.
Solution 3: Run the ‘npx’ command
You could also run the ‘npx’ command with the ‘ – – package’ flag.
npx --package typescript tsc --init
npx --package typescript tsc --version
Realize that we assigned the ‘ – – package’ flag to define the precise Typescript package. Then, use the Tsc command without prefixing it with ‘npx’, and even the ‘ – – package’ flag.
Let’s run your program and check the result. The error will be eliminated successfully.
Conclusion
That’s all about the “Tsc Command Not Found Typescript Error” and possible solutions you should consider. Do not forget to leave your request below this article.
Read more:
→ Cannot Find Module ‘X’ Error In TypeScript – How To Fix It?
Leave a comment