NodeJS NPM does not work

2

Folks, I installed the node normally and added to the environment variable; I did some math to test and it worked. When I tried to install modules (socket.io and express) it did not work, even running as administrator. I tried to check the command to test if npm is installed, but I get an error in return. The command was to check the version of npm: npm -v and this also did not work with node even if it is installed and working: node -v .

    
asked by anonymous 23.12.2015 / 11:04

3 answers

1

You are only running in the wrong place your command. The npm is the Node Package Manager , you do not need to "start" the node ( node + enter on your console ) to use it. Open command and type npm -v directly on the command line.

C:\Users\pfortesc>npm -v
2.14.4

As explained by @Sergio, the way you were doing node was trying to find the variable npm , since it does not exist, the exception was thrown.

    
23.12.2015 / 11:23
2

You are running in node mode and it should not be this way.

When you only write node you enter a JavaScript mode, ie you are in a JavaScript console. Then when you type npm it will interpret as a JavaScript variable and says it is not defined ...

Use directly on the console:

$ npm -v
$ # ou
$ node -v
    
23.12.2015 / 11:19
1

node and npm are two separate programs, and you were trying to run npm from within node , which clearly would not work. That is, you just run npm as a normal command in Windows Command Prompt.

Instead of doing this:

C:\Users\zignd>node
> npm -v
ReferenceError: npm is not defined
    at repl:1:1
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
    at REPLServer.Interface._ttyWrite (readline.js:830:14)
    at ReadStream.onkeypress (readline.js:109:10)

Do this:

C:\Users\zignd>npm -v
2.10.1
    
23.12.2015 / 11:26