How can i run NPM Commands in VSCode terminal? - node.js

i'm working on NPM terminal in VSCode as git and i installed an extension to support NPM but didn’t work and i just got that error
'npm' is not recognized as an internal or external command,operable program or batch file.
EDIT
i already installed node.js , i just want to work in the regular command prompt rather than node.js cmd and i got errors but it worked well when i open cmd as an admin after adding 'C:\Program Files\nodejs' to the path. now how i work with npm in cmd without opening it as an admin ? i think it’s a permissions issue tho.

You can run npm commands in a VSCode terminal the same way you would run them in any terminal:
npm <command>
This is assuming npm is properly installed.
Regarding the error you reported, maybe check this out:
'npm' is not recognized as internal or external command, operable program or batch file

What version do you have? It sounds like node is not installed.
Try to run npm -v to identify the version?

Related

Why "artillery" is not recognized as an internal or an external command?

I want to use artillery to test a nodejs app,
I installed artillery.io globally and I added the path to the environmen variables, but I still get the error
"'artillery' is not recognized as an internal or external command,
operable program or batch file.". I can't find similar issues on the web.
I couldn't install it in cmd first either, but then repeating same installation steps through Powershell (run as Administrator) worked fine.
Being:
install: npm install -g artillery
check installation: artillery -V
Look in the folder pointed out by
$yarn global dir and see if that folder is in your $PATH.
Or you can specify the a prefix when adding the package like below.
$yarn global add artillery --prefix /usr/local
you need to set environment variable path of npm
and my system npm path is "C:\Users\RanjitBarsa\AppData\Roaming\npm"
hope this works!!

Not able to run globally installed node packages

I have nodejs in my system. And I installed "http-server" globally using npm( npm install -g http-server). After installing http-server I tried to run http-server, but it is showing "'http-server' is not recognized as an internal or external command, operable program or batch file."
I have added "%AppData%\Roaming\npm;" in NODE_PATH and "C:\Program Files\nodejs\;/usr/local/share/npm/bin/;" in PATH. But still I have the same issue.
Can anyone help me on this.
Open command prompt and do following :
npm config get prefix
And append the output of above command to PATH for example:
o/p C:\Users\username\AppData\Roaming\npm
Do as set PATH=%PATH%;C:\Users\username\AppData\Roaming\npm
Run this:
export PATH="$(yarn global bin):$PATH"
Read more here

What is the 'npm' command and how can I use it?

What is npm?
Whenever I browse through some project they ask me to run npm command, something like this
npm install -g node-windows
I went through some blog posts to learn about npm and I installed Node.js. However, when I run the above code in Node.js, I get the following errors:
When I browsed further, I came to know that the windows user can run the command from the cmd prompt window, but when I do that I get some output like this:
Which just generate a text file nothing else.
My questions:
How can I get started with the AngularJS2?
How can I run an npm command?
Do I require a command prompt to run the npm command (in Windows), or I can just use Node.js?
When I use the command npm install in my command prompt, I get the following output:
How to get started with the angularJS2
Follow this link and set up the project by following instructions
How to run a npm command
npm stands for Node Package Manager, and therefore you need Node.js installed before you can run npm commands.
Follow this and install the latest version. And restart the command prompt.
Do I require a command prompt to run npm commands (in Windows), or can I just use Node.js?
Yes, you need to run npm commands from the command line (in Windows).
E.g., npm install
You get the warning because there is no package.json file present where you are running the command.
ENOENT stands for Error NO ENTrey
Navigate to the project folder using the following command and then run npm install
cd <projectpath>
The AngularJS 2 website has everything you need to be covered. Their quickstart guide alongside with the quickseed zip file helps a lot.
But, in case you missed some points:
yes, you will need npm/NodeJS. So, download the latest distribution and have a clean installation of it.
you can execute the npm command with its parameters from within the Windows cmd.
the quickseed ZIP file contains all the files you need to see a live and quick example running locally. Unzip it on your workplace and navigate to it using the windows cmd. When inside the root folder of the unzipped package, execute npm install and right after it npm start.
Take the learning path. Step by step, all your questions will be answered.
You need to use an admin prompt for global installation (-g).

Setting the global NPM folder

So ultimately, I am trying to install gulp by following this tutorial http://travismaynard.com/writing/getting-started-with-gulp, and I was having a lot of problems initially. I kept getting the error that "gulp is not recognized as an internal or external command", which is confusing to me because I found that by running npm ls that gulp had been installed properly. The command wasn't being recognized even after restarting command prompt. I found an article online http://blog.webbb.be/command-not-found-node-npm/ that I may have installed gulp in my local folder other than the global node_module folder. However, when I tried to reset the npm folder with npm config set prefix usr/local/, I received errors. If anyone can walk me through getting the global NPM folder set up and getting the gulp command to work properly, that would be much appreciated.
Try running command prompt as administrator,
or sudo since you seem to be on unix,
you install a package globally by using npm -g,

Running karma after installation results in 'karma' is not recognized as an internal or external command

I'm trying to run karma as part as an angular-seed project, after installing karma using
npm install -g karma
I get:
'karma' is not recognized as an internal or external command, operable program or batch file.
when i'm trying to run test.bat from angular-client\scripts, the content of this file is:
set BASE_DIR=%~dp0
karma start "%BASE_DIR%..\config\karma.conf.js" %*
I also tried to navigate to "\AppData\Roaming\npm\node_modules\karma\bin" and saw karma file, when I'm trying to run it I get again:
'karma' is not recognized as an internal or external command, operable program or batch file.
Any suggestions?
If not please suggest how to use jasmine without karma.
Thanks.
The command line interface is in a separate package.
To install this use:
npm install -g karma-cli
karma-cli
It is recommended to install karma with its Command-Line-Interface (karma-cli) which will take care of fetching the appropriate karma. You can also install a different local version specific to each project you're working on and karma-cli will pick the appropriate one.
From the karma installation page:
Typing ./node_modules/karma/bin/karma start sucks so you might find it useful to install karma-cli globally:
npm install -g karma-cli
Now, check that karma was installed by typing:
which karma //echo something like: /usr/local/bin/karma
and check that karma server is working (ctr+c to quit):
karma start
You can also check that karma was installed by going to this directory:
cd /usr/local/lib/node_modules/karma
Good luck!
On windows when you install a npm (non-globally - so without the -g flag), the executable commands are linked in the node_modules\.bin folder.
For example:
powershell> .\node_modules\.bin\karma start
powershell> .\node_modules\.bin\karma run
I had the same issue and fixed it by correcting my PATH environment variable.
STEP 1: go to the following path and ensure karma.cmd is present at the location given below
[Nodejs folder path]\node_modules\.bin <=> C:\Program Files\nodejs\node_modules\.bin
STEP 2: If present go to STEP 3, If not present run the following command npm install -g karma
STEP 3: Open environment variables and edit PATH
STEP 4: Add the following at the end :
[Nodejs folder path]\node_modules\.bin; <=> "C:\Program Files\nodejs\node_modules\.bin"
Log out your session and it will work for sure.
Based upon your directory using \AppData\Roaming, you're on Windows and this error is usually because the path to the npm globals isn't in the Windows PATH or NODE_PATH environment variables.
Use SET to check the values you are using for the paths and if your npm directory isn't listed, that will be the issue.
If you don't want npm to save to this directory, check the npm configuration options and the npm folders docs to see what you can change in this regard...
'karma' is not recognized as an internal or external command, operable
program or batch file.
If the above mentioned solution does not work, than
The cause of issue is previous version of nodejs. So uninstall the previous version of nodejs and re-install the latest version. It will resolve your issue. As I faced the same and by doing above changes it worked for me.
Thanks.
Official documentation at https://karma-runner.github.io/0.12/intro/installation.html is confusing. It implies that npm install -g karma-cli is to install karma globally but it actually required for to run karma from command line.
I had same: 'karma' is not recognized as an internal or external command, operable program or batch file. problem when i tried to install it directly to my project file. When i used npm install -g karma-cli to global install everything worked just fine.

Resources