require-anywhere

Require files relative to the position of your package.json

Usage no npm install needed!

<script type="module">
  import requireAnywhere from 'https://cdn.skypack.dev/require-anywhere';
</script>

README

require-anywhere

Require files relative to the position of your package.json

Install

npm install require-anywhere

Usage

var anywhere = require("require-anywhere")(__dirname);

// Requires the file 'utils.js' in '/path/to/your-app/libs/'
// where '/path/to/your-app/' is the directory where your package.json resides
var utils = anywhere("libs/utils");