Question

Using brunch I'm trying to do a check for if a module exists before trying to require it to stop an error.

Uncaught Error: Cannot find module "xxxxx"

if(require("filename")){
   require("filename"); 
}

But this does not work.

Was it helpful?

Solution

I used a try-catch to stop it from erroring.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top