I'm working on some cordova hooks that require shelljs. Now if a user doesn't have shelljs installed, they get this error message
module.js:340
throw err;
^
Error: Cannot find module 'shelljs'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
....
So this message is pretty ugly I want to provide a better message to the user. Is there anyway to prevent this message and then allow a custom message through console.log?
You can wrap it in a try-catch:
var shelljs;
try {
shelljs = require('shelljs');
} catch (ex) {
console.log('ShellJS is required');
process.exit(1);
}