# Update all npm packages in multiple projects in subfolders

> 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.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2023-04-26 | Topics: [CLI](https://flaviocopes.com/tags/cli/) | Canonical: https://flaviocopes.com/how-to-update-all-npm-packages-in-multiple-projects-that-sit-in-subfolders/

I used this shell script:

```javascript
#!/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
```
