I need to check if file/(custom)module js exists under some path. I tried like
var m = require(\'/home/test_node_project/per\'); but it throws error
var m = require(\'/home/test_node_project/per\');
You can just check is a folder exists by using methods:
var fs = require('fs'); if (fs.existsSync(path)) { // Do something } // Or fs.exists(path, function(exists) { if (exists) { // Do something } });