Reputation: 68975
I am new to node.js. I downloaded and install node.js installer from the official site. I have added this installer folder in PATH environment variable and I am able to run programs. But when I try to install some package using npm in node console it shows the error npm should be run outside of the node repl, in your normal shell
. I also tried it on a separate console. But it shows command not found though I have added node in the environment variable.
Upvotes: 51
Views: 161467
Reputation: 14883
If you're like me running in a restricted environment without administrative privileges, that means your only way to get node up and running is to grab the executable (node.exe) without using the installer. You also cannot change the path variable which makes it that much more challenging.
Here's what I did (for Windows)
npm install -g express
Running the installers through npm will now auto install packages where they need to be located (node_modules and the root)
Don't forget you will not be able to set the path variable if you do not have proper permissions. So your best route is to open a command prompt in the node.exe directory (shift right-click "Open command window here")
Upvotes: 14
Reputation: 629
you just open command prompt,
then enter in c:/>('cd../../')
then npm install -g cordova
Upvotes: 3
Reputation:
It's simple. Press the Windows logo on your keyboard. Then, type node.js command prompt in the search bar and run it.
Upvotes: 2
Reputation: 441
Do not run the application using node.js icon.
Go to All Programmes->Node.js->Node.js command prompt.
Below is example screen shot.
Upvotes: 26
Reputation: 31353
For Windows users, run npm
commands from the Command Prompt (cmd.exe), not Node.Js (node.exe). So your "normal shell" is cmd.exe. (I agree this message can be confusing for a Windows, Node newbie.)
By the way, the Node.js Command Prompt is actually just an easy shortcut to cmd.exe.
Below is an example screenshot for installing grunt from cmd.exe:
Upvotes: 124
Reputation: 94
You must get directory right path of program(node.js in program files).
such as
and use "npm install -g phonegap"
Upvotes: 1
Reputation: 68975
As mscdex said NPM comes with the nodejs msi installed file. I happened to just install the node js installer (standalone). To separately add NPM I followed following step
Upvotes: 6
Reputation: 106726
It's better to use the actual (msi) installer from nodejs.org instead of downloading the node executable only. The installer includes npm and makes it easier to manage your node installation. There is an installer for both 32-bit and 64-bit Windows.
Also a couple of other tidbits:
Installing modules globally doesn't do what you might expect. The only modules you should install globally (the -g
flag in npm) are ones that install commands. So to install Express you would just do npm install express
and that will install Express to your current working directory. If you were instead looking for the Express project generator (command), you need to do npm install -g express-generator
for Express 4.
You can use node anywhere from your command prompt to execute scripts. For example if you have already written a separate script: node foo.js
. Or you can open up the REPL (as you've already found out) by just selecting the node.js (start menu) shortcut or by just typing node
in a command prompt.
Upvotes: 11