It's possible to access variables inside a package.json file with $npm_package_[key]. I need to make something like this, but had no success:
{
"name": "core"
"version": "1.0.0"
"scripts": {
"first": "echo $npm_package_myvariable"
"second": "echo $npm_package_myvariable"
}
"myvariable": "$npm_package_name:$npm_package_version"
}
I need to reuse the value of the key myvariable in multiple scripts, but unexpectedly, the printed value is $npm_package_name:$npm_package_version instead of the expected core:1.0.0.
I'm currently using:
- nodejs version
v10.16.3 - macOS Catalina
v10.15.3