Skip to content
FLAVIO COPES
flaviocopes.com
2026

Update all npm packages in multiple projects in subfolders

By Flavio Copes

Learn how to update npm packages across many projects in subfolders with a small bash script that loops each folder and runs npx ncu -u plus npm update.

~~~

I used this shell script:

#!/bin/bash

for dir in */; do
    cd "$dir"

    if [ -f package.json ]; then
				rm -rf node_modules
        npx ncu -u
        npm update
    fi

    cd ..
done
Tagged: CLI · All topics
~~~

Related posts about cli: