del-nm

Delete `node_modules` and lockfiles

Usage no npm install needed!

<script type="module">
  import delNm from 'https://cdn.skypack.dev/del-nm';
</script>

README

del-nm

Delete node_modules and lockfiles

Package Version Downloads Status Build Status: Linux Coverage Status

Useful to perform fresh installation of dependencies.

Installation

npm install --save del-nm

Usage

$ tree
.
├── bar
│   ├── node_modules
│   └── yarn.lock
└── foo
    ├── node_modules
    └── package-lock.json
const delNm = require('del-nm');

delNm({ cwd: 'bar' }).then(paths => {
  console.log(paths);
  /*
    [
      '/Users/luftywiranda/bar/node_modules',
      '/Users/luftywiranda/bar/yarn.lock'
    ]
  */
});

delNm({ cwd: 'foo' }).then(paths => {
  console.log(paths);
  /*
    [
      '/Users/luftywiranda/foo/node_modules',
      '/Users/luftywiranda/foo/package-lock.json'
    ]
  */
});

delNm().then(paths => {
  console.log(paths);
  //=> []
});

API

delNm([options])

Returns Promise<Array> of deleted paths.

options

Type: Object

cwd

Type: string
Default: process.cwd()

Current working directory.

lockfiles

Type: boolean
Default: true

Set this to false to not delete lockfiles. Remember that npm-shrinkwrap.json will also be deleted when this option is set to true.

Related

License

MIT © Lufty Wiranda