I have a browser-based application that has a package.json (for managing dependencies using node.js).
However, I'd like to add some json meta-data to my app and I have two options: either create a new json file and add the data, or add it to the package.json.
The question is:
Is it recommended to add application-specific non-standard meta-data to package.json?
Where can I add this data? Under which key? _my_data
seems to be a good key, but I couldn't find any standard documentation about this.
Yes, you're allowed to add custom entries to package. json .
You can add dependencies to a package. json file from the command line or by manually editing the package.
you can just open it with nano and edit it manually...
To use variable, you need to declare a section named config (or something else, but not a name was already taken by the package. json ).
You are free to add arbitrary fields to package.json (and npm will not complain). So long as the file is valid JSON, npm
will look for the relevant fields (e.g. dependencies
for npm install
) and won't complain about additional fields
Assuming your dependencies are standard, the "recommended" approach is to keep a separate JSON file for non-standard data. This way, you can just copy or link to the standard package.json (and you are free to use arbitrary fields in your specific JSON file)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With