【发布时间】:2018-04-21 13:44:16
【问题描述】:
假设我的package.json 文件中有以下脚本:
{
"start": "node index.js",
"start-with-flag": "node index.js -f"
}
Insideindex.js 我有一个console.log(process.argv),上面的脚本输出如下:
$ npm run start
[ '/usr/local/Cellar/node/8.4.0/bin/node',
'/Users/.../test_app/index.js' ]
$ npm run start-with-flag
[ '/usr/local/Cellar/node/8.4.0/bin/node',
'/Users/.../test_app/index.js',
'-f' ]
是否可以检索我在index.js 内运行的脚本(start 或start-with-flag)的值?
【问题讨论】:
标签: node.js npm argv yarnpkg npm-scripts