resolve-from-npm
Resolve the path of a module from the directory where npm CLI is installed
const resolveFromNpm = ; require;//=> '/path/to/the/current/directory/node_modules/node-fetch-npm/src/index.js' async { await ; //=> '/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js'};
Installation
npm install resolve-from-npm
API
const resolveFromNpm = ;
resolveFromNpm(moduleId)
moduleId: string
(a module ID)
Return: Promise<string>
It resolves the path of a module from the path where npm-cli-dir resolves.
async { await ; //=> '/usr/local/lib/node_modules/npm/lib/install.js'}; async { try // npm CLI doesn't contain a file './hi' await ; catch err errcode; //=> 'MODULE_NOT_FOUND' errmessage; //=> "Cannot find module './hi' from npm directory '/usr/local/lib/node_modules/npm'." errnpmDir; //=> '/usr/local/lib/node_modules/npm' };
License
ISC License © 2017 - 2019 Watanabe Shinnosuke