Created
November 28, 2020 12:34
-
-
Save exuanbo/41a4a6206efcb22c1becb8b0aa3e050b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isModuleAvailable = (path: string): boolean => { | |
try { | |
require.resolve(path) | |
return true | |
} catch { | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment