pheromix
pheromix

Reputation: 19287

How to start a Nodejs server with options?

My computer runs Windows10 Enterprise.

I found this repo for creating a Nodejs server for tchatbot. As you can see there are options for starting the server. I tried to execute this command : node app.js DF_PROJECT_ID="agent-human-handoff-sampl-jseo" DF_SERVICE_ACCOUNT_PATH="D:\Docs\TchatBot\clé_account_service_agent_human_operator\agent-human-handoff-sampl-jseo-3349b2f01974.json"

But I got error : You need to specify a path to a service account keypair in environment variable DF_SERVICE_ACCOUNT_PATH

So what is wrong ?

Upvotes: 0

Views: 388

Answers (2)

jfriend00
jfriend00

Reputation: 707158

You can just set these in the environment in a command shell before running nodejs from that command shell:

set DF_SERVICE_ACCOUNT_PATH="D:\Docs\TchatBot\clé_account_service_agent_human_operator\agent-human-handoff-sampl-jseo-3349b2f01974.json"
set DF_PROJECT_ID="agent-human-handoff-sampl-jseo"

Then, you you can run your program and these variables will be in the environment that your node program inherits. If you want to automate this, you can create a small batch file that will set them and then run your program. Keep in mind that setting environment variables like this sets them on for programs run from the current command shell, not other command shells and not for programs run other ways.

After setting those, your environment is now configured and you would run your program just as always:

node app.js

Upvotes: 1

Jack Yu
Jack Yu

Reputation: 2425

It's basically same as jfriend00's solution, but I add node app.js in the end. And you just follow below sequence to run command.

set DF_SERVICE_ACCOUNT_PATH="D:\Docs\TchatBot\clé_account_service_agent_human_operator\agent-human-handoff-sampl-jseo-3349b2f01974.json"
set DF_PROJECT_ID="agent-human-handoff-sampl-jseo"
node app.js

By the way, if you use linux system or macOS, you'll use following command to start server.

(Just one line) DF_SERVICE_ACCOUNT_PATH="D:\Docs\TchatBot\clé_account_service_agent_human_operator\agent-human-handoff-sampl-jseo-3349b2f01974.json" DF_PROJECT_ID="agent-human-handoff-sampl-jseo" node app.js

Upvotes: 1

Related Questions