简体   繁体   English

命令行 arguments 到纱线启动

[英]Command line arguments to yarn start

I have created a react app with "start": "react-scripts start" in package.json.我在 package.json 中创建了一个带有"start": "react-scripts start" I run it using yarn start.我使用纱线启动运行它。 However, I want to pass an argument from command line eg yarn start -- test=hello and access it it in index.js .但是,我想从命令行传递一个参数,例如yarn start -- test=hello并在index.js中访问它。

I tried to access it using process.argvs but it is not there.我尝试使用 process.argvs 访问它,但它不存在。 How should I pass command line arguments to yarn start ?我应该如何将命令行 arguments 传递给yarn start

I don't think that react-scripts take command line arguments.我不认为反应脚本需要命令行 arguments。

If you want to pass arguments to node you will have to eject cra, then you will be able to pass arguments to node.如果要将 arguments 传递给节点,则必须弹出 cra,然后您将能够将 arguments 传递给节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM