check the module is native module or not
npm i --save is-native-modules
-
CommonJS
const isNativeModules = require('is-native-modules')
-
ES6 module
import isNativeModules from 'is-native-modules'
isNativeModules('path') // true
isNativeModules('other_module') // false
isNativeModules(['path', 'fs']) // [true, true]
isNativeModules(['other_module', 'some_module']) // [false, false]
isNativeModules([['path', 'fs'], ['other_module', 'some_module']]) // [[true, true], [false, false]]