UNPKG

vuepress-plugin-helper-live2d

Version:
25 lines (16 loc) 510 B
/** * @description Resolve the path of provided package name */ const path = require('path'); /** * Resolve the package path according to provided package name * @param {String} packageName Package need to be resolved * @return {String} If detected the package, the path; if not, null */ module.exports = function getNodeModulePath(packageName) { try { return path.dirname(require.resolve(`${packageName}/package.json`)); } catch (e) { return null; } };