package-resolve
Simple way to get the package.json for any installed package.
This finds the package.json
for any package installed in node_modules
so that if can be accessed by the running server.
It can also find the main
key and a style
key as well as
returning the package.json
as an object or the css as a
string.
This package uses native Promises throughout.
Install
npm install package-resolve
Example
The example is based on having installed bootstrap. It does
not need to have been require
d.
Pack = ;pack = 'bootstrap'; pack // file contains the path of the package.json file // err contains a descriptive error such as "File not found"
Usage
new
Pack = ;pack = <package to find>;
This should be passed the name of the package to find as listed under
dependencies
in our package.json
.
package
pack // file contains the path of the package.json file // err contains a descriptive error such as "File not found"
This returns a Promise that resolves to the full path of the package.json
file for this dependency.
resolve
pack // file contains the path of the `main` file in the package.json console;
style
packstyle // file contains the path of the file referred to in the style key console;
readPackage
pack // obj contains the contents of package.json as an object console;
readStyle
pack // css contains the css as a string console;
Problems
Any issues or comments would be appreciated at Github
Pull requests are welcome.