Package Exports
- tryrequire
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tryrequire) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Try Require
Try to require and if could not return undefined.
Install
npm i tryrequire --saveOptions
- log : will log error when could not load
- callback : will return function wich will have error parameter.
How to use?
var tryRequire = require('tryrequire'),
config = tryRequire('./config'), /* quitly try to load config */
info = tryRequire('./package', {log: true}), /* if error - log it */
niki = tryRequire('nicki', {callback: true});
niki(function(error, data) {
/* if could not load niki - in error would be information about it */
console.log(error || data);
});License
MIT