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 ?
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
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
Related
When I start neovide from my applications and run :checkhealth I get errors that node and other commands are not available. But when I start it from my terminal there is no error for those commands. I tried to copy and modify the neovide desktop file to start just nvim and see if there if something wrong with my my neovide installation. But also starting just nvim as application prints the same errors.
I'm using linux with plasma desktop
TL:DR; add a path variable
Depending on your configuration, nvim will need to know the environment to run some executables (like it is with node in your example). An easy solution is to add the path variable to the exec command in the according .desktop file. I remember that I had the same issue with node not being recognized in a configuration using my plasma installation. On gnome node was recognized and healthchecks were good, so I thought I didn't need the extra path. Later on I realized that I had trouble with other commands. E.g. when using fdfind to complete path commands. Again I had to search what the reason was and it also was the missing path.
To give an example, let's say you are using zsh and want to start neovide with multigrid enabled, the Exec line in your desktop file could look like:
Exec=zsh -c "source ~/.config/zsh/.zshrc && neovide --multigrid %F"
I have simple File Watcher that run TSLint. If I copy the command and run it in the console all fine but WebStorm run it with old Node version and throw error Buffer.alloc is not a function.
I'm using nvm to manage node.js versions.
ubuntu 16.4
Different Node.js versions are on your $PATH when you start your script from the IDE and from terminal.
When being launched from desktop/System menu, WebStorm only sees environment variables configured in login shell, but not in interactive shell configuration files (like .bashrc or .zshrc).
Possible workarounds:
Workaround 1: make required variables available in a login shell by moving them to the corresponding shell profile config
Workaround 2: run IDE from a terminal, either with the command line launcher or with bin/webstorm.sh
Workaround 3: edit the desktop launcher and set command to /path/to/shell -l -i -c "/path/to/webstorm.sh" (make sure that the shell you specified there has the needed variables configured in its interactive shell configuration file)
see also https://youtrack.jetbrains.com/issue/IDEABKL-7589
I am new to both linux and Node js basically we have developed Node js application in Windows and I need to deploy it on Debian 8 Jessie and I am able to deploy it on linux and for this I need to install npm, node js, grunt cli etc.
And to run my application I just need to type grunt using terminal and application starts.
But the problem I need to start server every time after reboot of system by typing grunt in terminal.
So need solution how can I start my application/server on machine start.
Also let me know how this stuff works!!.
Thanks
as always there is more than one way
rc.local
the prefered way. rc.local will be executed on system startup.
to edit the file use your favourite text-editor (e.g. nano) nano /etc/rc.local and add your script before the last line containing exit 0
/usr/bin/myscript -arg1 -arg2
exit 0
cronjob
if there is also the need for recurring tasks (e.g a daily backup), cronjob could be a good choice to keep things together.
Within your terminal type sudo crontab -e to edit your cronjobs.
there add your command with the #reboot time argument.
#reboot /usr/bin/myscript -arg1 -arg2
I'm working in a node application that can be started like this from a Mac machine:
DEBUG=app.* ENVIRONMENT=local node server/index.js
However, when trying to run that script in a Windows command line, I get the following message:
" 'DEBUG' is not recognized as an internal or external command, operable program or batch file."
When running the script without the parameters, I don't get any error.
How can I pass said parameters to my index.js from Windows?
Run this in the CMD window where you'll run your node app.
SET DEBUG=app.*
SET ENVIRONMENT=local
node server/index.js
Or if you want it to be in a single line, type this.
SET DEBUG=app.*&&SET ENVIRONMENT=local&&node server/index.js
To make this variable changes persistent, you should edit your environment variables in control panel.
I have a node webkit app, part of which involves using child processes in node to call pdftk (a separate command line program).
I don't want my users to have to install pdftk or use the command line, so I included pdftk in the packaged version of the node webkit app. If I run this packaged app from the command line, it works fine - and I assume that's because it's using the version of pdftk that's installed on my computer, not the one packaged with the app.
When I try to launch the app by double clicking on an icon in the gui, as I'd want a user to be able to do, I get a node.js error - child process ENOENT. I think that's because when launched through the gui, it doesn't inherit the environment variables (including PATH) from my command-line environment.
I know I can set environment variables as an option when I call the child process, but haven't been able to figure out how to do that correctly. I'm not sure what variable I should set, or what I should set it to. I suppose I'm not sure if it's even possible to call pdftk from within the packaged app, or if I would need to have the user install it on their own computer. Any help would be much appreciated.
I think this might not be about environment variables. I guess when you run from the command line your current working directory (CWD) is where the app is. And I think you set the path to pdftk relative to the node script. When you double click (a shortcut) the current working directory and the path where the node script is located are different so relative paths don't work as expected.
When you use relative paths, always use __dirname to get the path the node script is on and use it to set path to the pdftk file. The path.resolve function can be useful when doing this. Read path.resolve documentation
I strongly recommend you to check this question and answers
How do I get the path to the current script with Node.js?
What is the difference between __dirname and ./ in node.js?