How to execute node.js script by using .bat file? - node.js

I want to execute this script pm2 start d:\nodejs\ecosystem.config.js using .bat file
(I'm on windows 10)
but when I execute .bat file, it didn't work
I can't find any clues on any web, google

node d:\nodejs\ecosystem.config.js
Above command should execute the javascript file if the node is installed in the PC.

Related

Execute Node.JS terminal commands in a function

I have a Node.JS file and usually I run it with the terminal command node index.js, but I want to automate it. How would I be able to run that command in a function instead of the terminal?

node nssm http-server...service won't start

I have successfully used nssm to create a node service that runs in the background. I have done this, however, with .js files where you set the path to node.exe, then set the startup directory, then set the .js file you want to run in the arguments. Works great.
I'm trying to get http-server to run in the background, and I can't quite make it happen. The difference is, to run http-server, you don't run node.exe, just the 'http-server' command with a path after it. So, I'm scratching my head as to what I place in nssm for the path, startup directory, and arguments.
I've tried to place http-server "C:\path...etc." into a .bat file and run that with nssm, but when starting the service, I get the "Windows could not start the service on local computer..." error, and the service does not start. I've also tried to convert the .bat to a .exe and run into the same error.
Any help would be greatly appreciated!

Launch terminal window from go lang program?

I want to have a functionality in which i will create an go program running on linux system. When that program is running it will download a zip folder from server & extract it to user HOME directory. That extracted folder will have a shell script file eg. Update.sh.
Now i want once that file is extracted i want to open the terminal & run the shell script automatically which resides inside extracted folder. Kindly gudie me can i do that ?
Have you looked at the Go standard library? Your best bet is os/exec. I don't know how feasible it would be to open another terminal and launch the script in it, but you can pipe the output of the command launched by os/exec to the stdout of the terminal in which the go program was launched.
From your question, it sounds like the go program downloading and running the script is already being run by the user on the local machine. If this is not the case, then the above will not work.

Jenkins with linux machine for selenium script

I have created selenium testng.xml file and make windows batch file for my local window machine and Jenkins build now function perfectly working
But now client expectation is run jenkins projects for same selenium script in Linux server machine.
I m not aware about how can i start for my testng file for linux server?
You created batch file while working with testng.xml on Windows. You would create an equivalent shell file while working with testng.xml on Linux.
Once done, Go to Jenkins Job configuration build section and select Execute Shell option.
Put you shell script in command window or execute shell file directly from command window itself.
To execute shell file, use below syntax:
./<file>

Run nodejs npm package from notepad++ console

I'm trying to run some nodejs apps in Notepad++. I installed NppExec and node works just fine in the console, but npm packages don't run even though I installed them with the -g flag. My current workaround is to call cmd from the console and then running the app like:
// `cmd` inside Notepad++ console
C:\>lessc "$(FULL_CURRENT_PATH)" > "$(CURRENT_DIRECTORY)\$(NAME_PART).css"
How can I run it straight from the Notepad++ console without having to go into cmd?
Frankly this looks like a bug in NppExec, where it cannot run .cmd files from PATH.
A workaround would be to run:
where lessc
You'll get the path to the command like: C:\Users\username\AppData\Roaming\npm\lessc.cmd
Use that path inside NppExec console.
C:\Users\username\AppData\Roaming\npm\lessc.cmd "$(FULL_CURRENT_PATH)" > "$(CURRENT_DIRECTORY)\$(NAME_PART).css"
However I'd stick to the solution you already found, looks far more better to me.
Know this is old but still appears high up google results.
To run .bat or .cmd you need to add the extension.
npp.cmd start
From Docs Npp_Exec Manual:
The same approach can be used to execute .bat and .cmd files - but the file extension (.bat or .cmd) can not be omitted in this case.
cmd /c cd $(CURRENT_DIRECTORY) & node $(FILE_NAME) & pause

Resources