ld-check-dependencies

check npm dependencies at build time so you can tell the user to run npm install

Usage no npm install needed!

<script type="module">
  import ldCheckDependencies from 'https://cdn.skypack.dev/ld-check-dependencies';
</script>

README

Low Dependency Check Dependencies.

You probably shouldn't use this as it's only 5 lines of code. Here they are

function dependenciesNeedUpdating() {
  const childProcess = require('child_process');
  const result = JSON.parse(childProcess.execSync('npm install --dry-run --json').toString());
  return result.added.length > 0 || result.updated.length > 0 || result.removed > 0;
}

module.exports = dependenciesNeedUpdating;

Installation

npm install --save-dev ld-check-dependencies;

Usage

In JavaScript

const dependenciesNeedUpdating = require('ld-check-dependencies');
if (dependenciesNeedUpdating()) {
  throw new Error('please run `npm install`);
}

In npm

  ...
  "scripts": {
    "build": "ld-check-dependencies && rollup ..."
  },
  ...

License

MIT: ... though do 5 lines of code really need a license? ¯\(ツ)