I would like to launch my development server using a single launch script in a split console with ConEmu. It can be a ConEmu task, a batch script, or whatever it takes. I have achieved this with Gulp but find that solution to be overkill.
I need to execute
cd C:\Repo\myApp\frontEnd
npm start
I would then like to split the window cmd -new_console:s50H
And without waiting for npm start to finish, because it does not, execute the following in the new window. Syncronously so to speak.
cd C:\Repo\myApp\backEnd -new_console:s50H
node backEnd.js
Do you really care about executing npm start before creating new split with backend?
If you don't - the simplest way is starting backend before frontend. Actually, due to some minor delays in processing, your npm start may start same time or even before than node.
cd /d C:\Repo\myApp\frontEnd
node backEnd.js -new_console:s50H -new_console:d:"C:\Repo\myApp\backEnd"
npm start
Another option is starting npm in background and node thereafter.
cd /d C:\Repo\myApp\frontEnd
ConEmuC -async -c npm start
node backEnd.js -new_console:s50H -new_console:d:"C:\Repo\myApp\backEnd"
Related
I'm trying to create an executable file that runs two commands in two different folders.
I'm working on a react app with an express API and they are in two different folders. I was trying to create a .bat file that ran npm run dev in my API folder and then open a new terminal to run npm start in my app folder but I can't get it to work.
It is important that in opens two terminals in order to keep both processes open.
My code right now is this
#echo off
rem Change directory and run command in current command prompt
cd "path\one\"
echo Running 'npm run dev' in current command prompt
start cmd /c "npm run dev"
rem Open new command prompt window and change directory and run command
start cmd /k "cd path\two && echo Running 'npm start' in new command prompt && npm start"
Once it runs, it just says it cant find the specified route.
Any help would be appreciated!
Thanks a lot Mofi I finally got it working!
This is the code I used:
Edited mistake pointed by Mofi
#echo off
#start "npm start" /D"path1" %ComSpec% /D /C npm.cmd start
#start "npm start" /D"path2" %ComSpec% /D /K npm.cmd start
Once again thanks a lot! I now must figure out how to make it run npm i in both of them and run the other commands once npm i is over.
I have built an application that uses a ReactJS as frontend and Flask as middleware. I'm able to execute it using the following sequence of commands.
npm start
cd Equation-Solver
python -m flask run
After executing the first command, I have to open another terminal window and execute the next 2 commands. I would like to execute them together using a single shell script. Any help would be really appreciated.
Create a shell script. Add an ampersand at the end of the npm start line. This backgrounds that process. The other commands will then run. In this case the react app will show on the terminal, but the python app will be running also.
npm start &
cd Equation-Solver
python3 -m flask run
I am having trouble getting Jenkins to use the "npm" command from the "Execute shell" (under the "Build" step).
I am attempting to set up a new Jenkins instance (a copy from a previous one). I just imported the old jobs and am now getting the various services that these jobs depend on (e.g. maven, nodejs, ansible etc.) installed.
I am having trouble getting nodejs and npm, in particular, set up.
When I type the command "npm install" on the command line, I get the following:
uws#9.14.0 install /var/lib/jenkins/workspace . . .
. . .
Binary is fine
added 1282 packages in 36.424s
When I then attempt to run the same command using the Jenkins execute shell, I get the following:
+ npm install
/tmp/jenkins7750702649955218109.sh: line 2: npm: command not found
Build step 'Execute shell' marked build as failure
Why would this command be accessible to me from the command line but not to Jenkins?
Some things I have checked:
-The path to "node" and "npm" are both on the path. At least "shortcuts" are on the path (this worked in the previous Jenkins instance).
-The node and npm binaries have root:root ownership, but their security settings are (currently) 755 (or -rwxr-xr-x).
-I have the nodejs plugin installed. Not sure of how to use it, but its settings match those on the previous Jenkins instance. Both instances use the execute shell (as opposed to any special Jenkins tool) to run the "npm" commands, whilst only the old version worked.
So, what else should I be checking that I am not? What does Jenkins require to access the "npm" command?
Try this below options in Jenkins
Option 1:
Option 2:
I have a NodeJS server that I run using npm startand an AngularJS client UI application that I also run using npm start, is there a way to create a desktop shortcut to run the command lines with just a click?
As mentioned in my comment, a batch script seems like the easiest way of doing this. If you're on Windows, this should do what you need:
start cmd /k "cd C:/yournodeproject && npm start"
start cmd /k "cd C:/yourangularproject && npm start"
start runs a command in a new window.
cmd /k allows us to pass a string into the new command line.
Each window switches to the relevant directory and runs npm start.
Unfortunately I don't know enough about Bash to offer a Linux equivalent, but hopefully this will get you started.
I have a very simple batch file that is suppose to query for a list of installed node modules.
However my batch file will automatically closed upon getting the return of the list.
#echo off
npm list -g --depth=0
pause
Why is this happening as I already have the 'pause' syntax at the end of my script
Probably because npm is a batch script. Executing one batch script from another will transfer execution. If you want to return when the second script finishes, you need to call the second script
call npm list -g --depth=0
should act as you expect.
No guarantees though, since you don't reveal the precise nature of npm.