Asked  7 Months ago    Answers:  5   Viewed   86 times

In my package.json I have these two scripts:

  "scripts": {
    "start-watch": "nodemon run-babel index.js",
    "wp-server": "webpack-dev-server",
  }

I have to run these 2 scripts in parallel everytime I start developing in Node.js. The first thing I thought of was adding a third script like this:

"dev": "npm run start-watch && npm run wp-server"

... but that will wait for start-watch to finish before running wp-server.

How can I run these in parallel? Please keep in mind that I need to see the output of these commands. Also, if your solution involves a build tool, I'd rather use gulp instead of grunt because I already use it in another project.

 Answers

84

Use a package called concurrently.

npm i concurrently --save-dev

Then setup your npm run dev task as so:

"dev": "concurrently --kill-others "npm run start-watch" "npm run wp-server""
Tuesday, June 1, 2021
 
chugadie
answered 7 Months ago
74

You need to manually create a symlink /usr/bin/node. Shortcut for bash compatible shells:

sudo ln -s `which nodejs` /usr/bin/node

Or if you use non-standard shells, just hardcode the path you find with which nodejs:

sudo ln -s /usr/bin/nodejs /usr/bin/node

Later edit

I found this explanation in the link you posted

There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed from node to nodejs. You'll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.

Later later edit

It's been a while since I answered this. Although the solution I posted up here worked for me several times, users have reported a few more solutions within the comments:

From @user229115

sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

From AskUbuntu (user leftium)

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs
Tuesday, June 1, 2021
 
WooDzu
answered 7 Months ago
96

With && you can execute more than one commands, one after another:

Runtime.getRuntime().exec("cmd /c "start somefile.bat && start other.bat && cd C:\test && test.exe"");

Using multiple commands and conditional processing symbols

You can run multiple commands from a single command line or script using conditional processing symbols. When you run multiple commands with conditional processing symbols, the commands to the right of the conditional processing symbol act based upon the results of the command to the left of the conditional processing symbol.

For example, you might want to run a command only if the previous command fails. Or, you might want to run a command only if the previous command is successful. You can use the special characters listed in the following table to pass multiple commands.

& [...] command1 & command2
Use to separate multiple commands on one command line. Cmd.exe runs the first command, and then the second command.

&& [...] command1 && command2
Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.

|| [...] command1 || command2
Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).

( ) [...] (command1 & command2)
Use to group or nest multiple commands.

; or , command1 parameter1;parameter2
Use to separate command parameters.

Wednesday, June 30, 2021
 
BrunoRamalho
answered 6 Months ago
34

"simply" this way...

const source = 
  [ { title: 'Expanse', season: 1, episode: 1, path: 'download.mkv'} 
  , { title: 'Expanse', season: 1, episode: 2, path: 'download.mkv'} 
  , { title: 'GoT', season: 7, episode: 1, path: 'download.mkv'} 
  , { title: 'GoT', season: 8, episode: 1, path: 'download.mkv'} 
  , { title: 'GoT', season: 8, episode: 4, path: 'download.mkv'} 
  ]
  
const result = source.reduce((a,{title,season,episode,...more} )=>
  {
  let titleX = a.find(x=>x.title===title)
  if (!titleX)
    {
    titleX = { title, seasons:[] }
    a.push(titleX)
    }
  let seasonX = titleX.seasons.find(x=>x.season===`season ${season}`)
  if (!seasonX)
    {
    seasonX = { season:`season ${season}`, episodes:[] }
    titleX.seasons.push(seasonX)
    }
  seasonX.episodes.push({ name:`episode ${episode}`, ...more })
  return a  
  },[])

  
console.log(  result )
.as-console-wrapper { max-height: 100% !important; top: 0; }
Sunday, August 29, 2021
 
Bram
answered 4 Months ago
85

You need to edit confserver.xml for the second Tomcat/TeamCity instance so that it uses different ports or binds to different network interfaces, changing the following ports should be enough:

  • Server port="8005"
  • Connector port="8080"

Two servers cannot share the same database, so you must configure them to use different locations via TEAMCITY_DATA_PATH environment variable.

If you also want to run multiple agents on the same machine, refer to my answer here.

Monday, September 6, 2021
 
Angshuman Agarwal
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share