clean_node

This script will delete both the node_modules directory and the package-lock.json file in the given directory ($PWD if not given).

This is useful to get a clean slate after dependency updates.

Copy the script into your Node.js project and add it as a custom script to your package.json file:

package.json
{
...
  "scripts": {
    "clean:node": "scripts/clean_node.sh"
  }
}
$ npm run clean:node
$ npm i

Usage

$ scripts/nodejs/clean_node.sh
$ scripts/nodejs/clean_node.sh /tmp/nodejs-example-project