I'm writing a NPM module for a cli-based tool. After someone installs the package, I need to read their package.json
file. I know how to read the file in syntax. My question is, how can I consistenly retrieve the package.json
file and should I use relative or absolute paths.
So, after installing, my code would reside somewhere inside the node_modules
folder:
package.json // I need to require this file
node_modules/
↳ my-package/
↳ dist/
↳ my-package.js // the actual file running the code
Any suggestions/best practices? Or is it just a matter of using the right filepath?
via Nicky
No comments:
Post a Comment