Running node.js code just displays a node identifier

Don't break your Harvest SCM by removing it from path. Try this one, open your windows command line (cmd) and then pass the following nodejs batch file so that it will set your command line to nodejs environment. Enjoy the node commands there.

C:> "C:\Program Files\nodejs\nodevars.bat"


This happens when Harvest SCM is installed on your system. It has an executable with the name node.exe at <Program Files (x86)>\CA\SharedComponents\PEC\bin (where <Program Files (x86)> is your x86 program files folder). This path is present in your PATH variable before the path to Node.js's node.exe.

Update: You don't need the elaborate scheme listed in the old answer. You just have to open the Command Prompt and run:

C:\> nodevars

nodevars.bat is a small script that does essentially the same thing described below (but in a safer way). If you have node installed, this script should be in path. (If not make sure to add C:\Program Files\nodejs to your path. But make sure to append it in the end so Harvest SCM does not break).


Everything below is outdated, but I will leave it for the curious reader.

You can do either of following two things you can do to overcome this problem:

  1. Remove <Program Files (x86)>\CA\SharedComponents\PEC\bin from PATH environment variable.
  2. Add/move <Program Files (x86)>\nodejs to the beginning of the PATH environment variable (This is the currently accepted answer from djrpascu).

You can do better!

There are two problems with the above approaches:

  1. You break Harvest SCM's functionality.
  2. If you do not have elevated privileges to change PATH, you are out of options. (Thanks @Glats)

So I created this little batch file, and put it in a directory where I have several other personal scripts (this directory is in my PATH). Here's the gist for the script.

nodecmd.bat

@echo off

set path=%path:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;C:\Program Files (x86)\nodejs;

start %ComSpec%

Then the next time you want to run Node.js, instead of Command Prompt, you open the new script with "Run..." command.

Windows+R

nodecmd

A command prompt will appear. You can use this command prompt to run node without a hassle.

Explanation

This bit deletes the Harvest's executable's path from PATH variable:

%path:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;

And this adds the Node.js's path:

set path=...;C:\Program Files (x86)\nodejs;

The result is a string that contains the original PATH variable minus Harvest's path, plus Node's path. And it is set as PATH variable in the scope of current batch file.

Note: You might have to change the path's in the script to suit software installation folders in your system).

Next line, start %ComSpec% starts a Command Prompt. By this time, the PATH variabe is modified. With modified environment variables, you can run node within this new Command Prompt. The environment variable modification does not affect the rest of the system, making sure that Harvest SCM software runs without breaking.


Was getting this when I was trying to run cordova commands. Steps to resolve:

Windows

  1. In CMD prompt, type "where node". As Michael mentioned, this shows you the likely culprit, that you have 2 nodejs EXEs installed on your machine.
  2. Navigate to Start > Computer > Right-click Properties > Advanced system settings
  3. Under the Advanced tab, select Environment Variables
  4. Under System variables, select "Path" variable
  5. Find nodejs EXE, usually "C:\Program Files (x86)\nodejs\"
  6. Cut and paste this to the beginning of the "Path" variable. Ensure the paths are separated by a ";"
  7. Open a new CMD prompt and try cordova again

Tags:

Node.Js