Running multiple npm tasks concurrently using a ".sh" file in Windows: a step-by-step guide

Brand new to ".sh" right now when faced with this question. I am not even certain what ".sh" refers to - Shell, Powershell, Bourne shell, etc. Currently, I am operating from a Windows OS.

The goal of this question is:

  1. Change directories
  2. Run the npm script (ensure it continues running without being terminated)
  3. Change directories
  4. Run another npm script (ensure it continues running without being terminated)

Tasks 2 and 4 need to be executed without interruption.

My initial code snippet is as follows:

cd UAA_Generators/JapaneseSyntax/ByNodeJS/DataStructures/Tokens || exit
npm run "Incremental building"

cd ../ModulesCollection || exit
npm run "Incremental building"

Currently, only the first task has been completed.

Answer №1

I was a bit confused about your statement regarding executing tasks without being killed while running. If you want npm runs to be background tasks and not hold up the script, you can use the '&' operator at the end of the command line.
For example, the following script will run "incremental building" as a background task, then switch directories and run "Incremental building" in the ModulesCollection directory:

#!bin/bash
cd UAA_Generators/JapaneseSyntax/ByNodeJS/DataStructures/Tokens 
npm run "Incremental building" &

cd ../ModulesCollection 
npm run "Incremental building"

If you want both commands to run simultaneously without waiting for them to finish, simply add another '&' after each 'npm run' command.

It's unclear why you included '|| Exit' after changing directories. Is there additional code missing? It's generally not recommended to prematurely exit your shell before completing tasks, which may have caused issues with your script execution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Powershell throwing error due to unsigned Firebase script

While setting up a new project with Firebase, I encountered an issue after running the firebase init functions command. The error message displayed is as follows: firebase : File C:\Users\fudge\AppData\Roaming\npm\firebase.ps ...

An array is not just a mere collection of elements

I have an object that resembles an array var items = [ { started_time: 2017-05-04T12:46:39.439Z, word: 'bottle', questionId: '161013bd-00cc-4ad1-8f98-1a8384e202c8' }, { started_time: 2017-05-04T12:47:26.130Z, word: &apo ...

When a node_module package includes type imports, Next.js can encounter build failures during the linting and type validity checking processes

This NextJS 13 project utilizes a package that has an inner core dependency (react-leaflet->@react-leaflet/core). When running yarn run build, the build fails at "Linting and checking validity of types." It appears to be a TypeScript compatibility iss ...

What are some strategies for preventing unused setState functions in React? Is it possible to create a React useState without a setter function

Currently working on reducing or eliminating npm warnings related to the React site. Many of these warnings are due to the setState function, which is marked as 'unused' in the code snippet below. const [state, setState] = useState('some st ...

Developing a Node Express API that sends image files as responses

I tried searching online for a solution to this issue, but it seems quite common. This question is similar to another unanswered one on Stack Overflow regarding Node request and reading image streams. My problem involves sending an image file as a respons ...

Encountering a Next.js redirect issue with 'The page is not redirecting properly' in _app.js

I'm currently working on the user authentication section of a nextjs app. The majority of it is done, except for the protected routes. I'm trying to manage the authentication aspect in _app.js. Below is the code snippet: import App from 'nex ...

When deploying my website on Heroku, I utilize mongoose.connect().'

After successfully setting up node.js, npm, mongodb, and mongoose to develop a website with a database locally, I utilized mongoose.connect('mongodb://localhost/test') without any issues. Everything was functioning as expected. However, upon att ...

What is the process of creating a for loop in FindById and then sending a response with Mongoose?

Is there a way to get all the data in one go after the for loop is completed and store it in the database? The code currently receives user object id values through req.body. If the server receives 3 id values, it should respond with 3 sets of data to th ...

Install from npm using VSO

Seeking assistance from the SO community, I am facing an issue with running npm install -s from a git repository hosted on Visual Studio Online. Despite having successfully done this from GitHub and Bitbucket before, the process does not seem to work in th ...

Best Practices for Safely Storing the JWT Client Credentials Grant

Currently, I am working on a NodeJS Express Application that connects to an Auth Server using client credentials grant. After receiving the token from the Auth Server, I use it to access data from an API. I am seeking advice on the most effective way to s ...

Encountering issues during the installation process of Yarn

I am facing an issue while trying to set up yarn on a new machine. When I input brew install yarn in the command line, I receive the following output: touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied touch: /usr/local/Homebrew/Library/Taps/ho ...

Using faceapi.js with nodejs and express

I'm in the process of creating a real-time face recognition model using faceapi js with node and express. I've attempted to detect faces using the following code. https://gist.github.com/Dannybrown2710/5e30c063da936ee947d8fff474f9f57b However, ...

Retrieve user login information from an external website after logging in with Node.js in a web browser

Is it possible to extract information from a pop-up window of a user's login on an external website after the user has logged in successfully while using Node.js in a web browser (similar to how Puppeteer can accomplish this through the terminal)? ...

What is the reason for multiparty.Form() generating temporary image files post-upload?

While using Node.js to upload an image, I noticed that the same image is created with a temporary name like G-fMNpe9OCU3NdLzPxnRT-X2.png. I am able to successfully upload the image without any issues, but I'm curious why these duplicate images are bei ...

Steps for converting SCSS to CSS using node-sass

I have a main.scss file with numerous imports from other .scss files. Whenever I make changes to any of the *.scss files, the master.css file is automatically generated. I rely solely on NPM for my build process and do not use Gulp or Grunt! It's imp ...

Ways to resolve the issue "Module Not Found Error: Cannot locate module './src/bot/index'"

Whenever I run the command node src/index.js I encounter the following error message: Error: Cannot find module './src/bot/index' Require stack: C:\Users\MIMAR\Desktop\EJS\src\index.js What could be causing this er ...

Is it possible to set up a universal type definition in TypeScript version 2 and above?

I have a collection of straightforward .ts files, not part of any projects but standalone .ts scripts. They implement certain node.js features. Both TypeScript and node type definitions are set up through the following commands: npm install -g typescript ...

Stuck in a possible freeze while verifying the session cookie within firebase authentication

When attempting to verify the sessionCookie using the code snippet below, the process freezes without displaying the log(sessionCookieString). What could be causing this freeze? node.js export const sign = functions_address.https.onCall( (data,conext) =& ...

Failures in React-router on the server side

I am currently working on making my client-side webapp isomorphic and came across a helpful pattern on Client Routing (using react-router) and Server-Side Routing. Here is what I have implemented: server.js: var React = require('react'), expre ...

The Docker container running NodeJs on Windows is automatically shutting down

I am encountering an issue with NodeJS that keeps shutting down shortly after running the command to execute it. To begin, I created a React project using the command create-react-app <my_project_name>. Next, in the project directory, I made a Docke ...