*package.json**
{
"name": "test-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node build build_name"
},
"author": "",
"license": "ISC",
"devDependencies": {
}
}
build.js
console.log("Building Code. Output File Name:", process.env.build_name);
Command Line
$ npm run build build_name="web"
I want to pass a parameter build_name
from the command line while executing build
script. I will use that param inside my build
script. Can someone tell me how to achieve this? Also if I did not pass build_name
from the command line, can we send a default value from here "build": "node build build_name"
instead of build_name
.