I cannot execute commands such as tsc
unless I include npx
before it (e.g npx tsc
). How can I fix this?
The title is a bad explanation of the problem I have.
Say I have installed an npm package with a CLI with it (typescript in this example). And the CLI is used like
tsc <filename>
or just tsc
. But whenever I try to do it like that, I get an error like
'tsc' is not recognized as an internal or external command,
operable program or batch file.
But... when I do
npx tsc
then it works!
The problem with doing npx tsc
is because
npx
and the front of every command.And the thing is, this was originally not a problem with WSL.
I have always had problems with WSL (primarily permission issues due to security reasons) and so I uninstalled WSL and just used command prompt. I would have perferred using WSL but it was simply not an option.
Other Info:
So is there a way to just execute commands that way or is it Command prompts fault?
Ok, so I came across this post and thankfully, the first answer there was the solution!
Just add %USERPROFILE%\AppData\Roaming\npm
to the path variable in system variables!
To access the system variables, press the Windows key, type Environment variables
and click on Environment variables
at the bottom of the window. The path variable can be found under User variables for (profile name)
.