How to "start" a Node server?

1

I installed the Node, created the environment variable ( NODE_ENV ) value development.

When I installed and configured, I printed a arquivo.js with hellow world and it worked.

Today, I want to start the server, but I can not. I already set set node_env and the environment variable is ok. I already typed in the terminal node -v , but it does not show the version, Windows does not recognize this command.

How do I start and keep the Node server running?

    
asked by anonymous 24.08.2015 / 14:31

2 answers

3

Probably, although you create the variable NODE_ENV, it is not in the Windows PATH, this is necessary for Windows to recognize the command you are executing, in this case the node -v.

Do this in the advanced properties of the system, in the Advanced tab, environment variables.

Another option is to set this via the command line, I do this with a BAT, to simplify the process, so only the variables when I really need them. Here is an example of what BAT would look like:

SET NODE_ENV=<caminho_node>
SET PATH=%PATH%;%NODE_ENV%

Note that in this case the environment variables will only be valid for the current session. Then do the BAT, save in the working directory of the node, and before starting to run the node, execute the bat.

    
24.08.2015 / 15:39
2

In windows, the node provides the nodevars.bat file that assigns the path to NodeJs and NPM to the PATH.

C: \ Program Files \ nodejs or C: \ Program Files \ nodejs

To keep the application running you can use Forever or PM2.

link

link

    
24.08.2015 / 15:52