2 years ago

#75356

test-img

Thijmen

How to wait for an NPM command to finish before proceeding to the following command?

I created a shell script that intends to remove all node modules, reinstall them, build the code base, and start the server. Part of it looks like this:

# Install backend
rm -rf "./backend/node_modules/"
npm ci --no-fund --prefix "./backend"  # <-- (1)

# Build backend
npm --prefix "./backend" run build     # <-- (2)

However, what happens is that the run build command (1) executes before NPM has finished installing all packages (2).

How can I make sure that (1) has finished before (2) is executed?

node.js

shell

npm

wait

0 Answers

Your Answer

Accepted video resources