【发布时间】:2021-07-12 23:47:00
【问题描述】:
我有一个 npm 脚本,它是这样运行的:
npm run start:local -- -target.location https://192.1.1.1:8052/
URL 参数是用户的本地 IP。
我希望让用户输入这个值,因为每个人都不同。
有可能吗?使用 vanila npm 脚本会很棒。
【问题讨论】:
-
这能回答你的问题吗? Sending command line arguments to npm script
-
不,它没有(或者至少我找不到它建议如何要求用户输入参数)。
-
您可以从您的 npm 脚本中调用一个 bash 脚本,该脚本会从用户那里读取一个参数。有很多交互式 bash 脚本示例。
-
但是在节点领域我希望必须以 URL=localhost npm run start 的方式运行它
-
package.json文件的“脚本”属性的内容是什么?
标签: npm