To access a variable in npm scripts you would do something like this in your package.json:
\"scripts\": {
\"preinstall\": \"echo ${npm_packa
There's no known way to do this that's OS independent.
A good workaround is to execute the command within a node script:
First, change the preinstall command to execute a node script:
"scripts": {
"preinstall": "node nameEcho.js"
}
Then you define the command in the nameEcho.js file:
// require the package.json file
var pjson = require('./package.json');
// echo the package's name
console.log(pjson.name);