Why doesn't npm modules' commands work in VSCode Terminal? - node.js

If I type any Nodejs command in Vscode Terminal there comes the error
The term "nodemon" was not recognized as the name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if the path is correct (if included),
and repeat the process.
It also doesn't works in external Terminal but it works in Terminal which isn't opened by VSCode.
Thanks for your help!

If you're using windows, you should use the npx command to run modules.
It should come preinstalled alongside npm
npx nodemon

You have to make sure that the variables:
C:\Program Files\nodejs\
C:\Users\(your Username)\AppData\Roaming\npm\node_modules
are present in your system environment variables under the path tab.

Related

VSCode Terminal: The term 'node' is not recognized as the name of a cmdlet

The problem is that I can actually access the C:\Program Files\nodejs\node.exe through Windows CMD like : node -v:
C:\Users\User>node -v
v16.13.0
But the Visual Studio Code (with installed node.js extension pack) doesn't recognize the node in terminal. All that I could have found myself is that:
I should include the nodejs folder in my PATH variable (done already) and
restart my PC
restart IDE.
All of the three steps were done but still VSCode doesn't recognize the "node" command in terminal.
node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
Everything is working for now, I just had to manually close and re-open terminal through VSCode -> Terminal -> New Terminal, also pressing the "Powershell" button on terminal panel could've solved the issue.

How to run NodeJS CLI tools without having to type npx

TL;DR
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!
So whats the problem?
The problem with doing npx tsc is because
npx is slow at executing commands
its annoying having to type npx and the front of every command.
And the thing is, this was originally not a problem with WSL.
Why dont you just use 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:
I am using Windows command prompt.
I have installed the packages globally
So is there a way to just execute commands that way or is it Command prompts fault?
! this only works for Windows !
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).

YEOMAN YO ERROR yo it is not recognized as an internal or external command, program or batch file executable.

When installing node.js for the first time and using the YEOMAN library, I found that it did not recognize the library despite installing it correctly.
When executing in console
yo swaggerize
Returns the error "yo it is not recognized as an internal or external command, program or batch file executable"
After several laps the problem is in node.js and in the PATH.
I post the solution in the next post.
The solutiĆ³n for me, it's simple.
In windows-> go to pc properties->advanced configuration-> environment variables
Show Path variable and edit.
C:\Users\youruser\AppData\Roaming\npm;
C:\Program Files\nodejs;
Save restart your console and run the command again
Each and every thing was fine
only problem was path
so I set path in environment variable.
This path I set in environment variabel
C:\Users\user\.npm-packages
where 'user' is my user name, please use your user name.
Then my 'yo', 'bower' command start to executed
Thanks

node command line module commands are not working Windows 8

So I'm having a lot of trouble getting my node module command line commands to run correctly.
For example if I try and run gulp I get a
>gulp
'gulp' is not recognized as an internal or external command,
operable program or batch file.
So I have tried making my environment variable NODE_PATH
%APPDATA%\npm\node_modules\
%APPDATA%\npm\node_modules
%APPDATA%\npm
but none of these seem to work. The only command I can use to get my gulp to run with is
C:\Users\Aaron\Documents\GitHub\2015fallTeam14>node %NODE_PATH%gulp\bin\gulp
[12:10:32] Using gulpfile ~\Documents\GitHub\2015fallTeam14\gulpfile.js
It would appear that cmd is not running my node with my NODE_PATH variable along with my command, but I do not know how to to fix this
You need to set the system PATH variable to tell the command prompt where to find gulp.bat (which npm creates).
This has nothing to do with Node itself.
I had add the following
Edit "PATH" environment variable and add %APPDATA%\npm
from
https://stackoverflow.com/a/27295145/4249440
Im not sure why this works though. I would like to know how the cmd knows to run node on this file path.

I can't run test with "vows test/*" command on windows. How to use it? node.js

I've installed vows as module of my project and I've added the path "node_modules\vows\bin" to my environment path variable of windows vista.
note: I've also renamed "node_modules\vows\bin\vows" to vows.exe, because without the extension I get this error: 'vows' is not recognized as an internal or external command,
operable program or batch file.
Now wherever I put "vows" in my cmd in windows nothing happens, I cd into my test folder and I run "vows myFirstTest.js" and nothing happens. (when I say nothing happens my cursor in cmd is going to the top and then return to it's original position and it's doing this forever, therefore each time I try a vows command in cmd I have to close the cmd to run another command).
What I'm doing bad?
thanks
NPM is great at globally installing packages and making the executable for each operating system (UNIX-ish + Windows), so proceed with the following:
npm install -g vows

Resources