Enables a module to require itself by name
Last updated 3 years ago by lukechilds .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install requirable 
SYNC missed versions from official npm registry.


Enables a module to require itself by name

Build Status Coverage Status npm

Mocks the require command to include the current package when the name from the current package.json is required.

Uses process.cwd() to find the current package.json so this is only meant to be used in scripts executed from the CLI. This will not work on a published package!


npm install --save-dev requirable


// That's it! `require` has now been patched

const myPackage = require('package-name')

AVA Usage

Some tests runners such as AVA can require packages automatically for you. If you're using AVA add the following to your package.json:

"ava": {
  "require": [

You can now require (or import) your package in your AVA tests by name.

e.g instead of:

import test from 'ava';
import myPackage from '../';

You can now do:

import test from 'ava';
import myPackage from 'package-name';



Patches the require function to be able to require the current module by name.

Returns an object.


Type: boolean

True or false depending on whether we could find package.json.


Type: undefined, string

Path to the folder containing package.json.

Type: undefined, string

Name of the module in package.json.


MIT © Luke Childs

Current Tags

  • 1.0.5                                ...           latest (3 years ago)

7 Versions

  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 7
Dependencies (2)
Dev Dependencies (5)
Dependents (2)

Copyright 2014 - 2017 © |