documentation
documentation copied to clipboard
[BUG] package.json vars documentation seems outdated
What / Why
Apparently many package.json vars have been removed since v6 (reference). But docs are still pointing to them here:
You can access these variables in your code with
process.env.npm_package_nameandprocess.env.npm_package_version, and so on for other fields.
and here:
Objects are flattened following this format, so if you had
{"scripts":{"install":"foo.js"}}in yourpackage.json, then you'd see this in the script:process.env.npm_package_scripts_install === "foo.js"
References
- https://github.com/npm/cli/issues/2609
- https://docs.npmjs.com/cli/v8/using-npm/scripts#packagejson-vars
- https://docs.npmjs.com/cli/v8/using-npm/scripts#current-lifecycle-event
{
"scripts": {
"precompress": "{{ executes BEFORE the compress script }}",
"compress": "{{ run command to compress files }}",
"postcompress": "{{ executes AFTER compress script }}"
}
}