You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rich Trott aaee43473b tools: update to ESLint 4.1.0 8 years ago
..
LICENSE tools: update eslint to v1.10.3 9 years ago
README.md tools: update ESLint to 2.9.0 9 years ago
index.js tools: update eslint to v1.10.3 9 years ago
package.json tools: update to ESLint 4.1.0 8 years ago

README.md

is-resolvable

NPM version Build Status Build status Coverage Status Dependency Status devDependency Status

A Node module to check if a module ID is resolvable with require()

const isResolvable = require('is-resolvable');

isResolvable('fs'); //=> true
isResolvable('path'); //=> true

// When `./index.js` exists
isResolvable('./index.js') //=> true
isResolvable('./index') //=> true
isResolvable('.') //=> true

Installation

Use npm.

npm install is-resolvable

API

const isResolvable = require('is-resolvable');

isResolvable(moduleId)

moduleId: String (module ID)
Return: Boolean

It returns true if require() can load a file form a given module ID, otherwise false.

const isResolvable = require('is-resolvable');

// When `./foo.json` exists
isResolvable('./foo.json'); //=> true
isResolvable('./foo'); //=> true

isResolvable('./foo.js'); //=> false


// When `lodash` module is installed but `underscore` isn't
isResolvable('lodash'); //=> true
isResolvable('underscore'); //=> false

// When `readable-stream` module is installed
isResolvable('readable-stream/readable'); //=> true
isResolvable('readable-stream/writable'); //=> true

License

Copyright (c) 2014 - 2015 Shinnosuke Watanabe

Licensed under the MIT License.