简体   繁体   English

env-cmd 中不允许使用美元符号

[英]Dollar sign not allowed in env-cmd

I would like to ask if what's wrong with the dollar sign within the environment variable?我想问一下环境变量中的美元符号有什么问题? I tried to do everything to fix the problem I've encountered using env-cmd package from npm with react我尝试尽一切努力解决我遇到的问题,使用来自 npm 的 env-cmd package 和反应

Sample样本

.env.development

REACT_SECRET_CODE=$B&FG%@(*4Fgawq@)

After a few hours of debugging then until I've noticed that it removes the $ sign from the example env variable REACT_SECRET_CODE then the variable shown in the console log is &FG%@(*4Fgawq@) instead of $B&FG%@(*4Fgawq@)经过几个小时的调试,直到我注意到它从示例环境变量REACT_SECRET_CODE中删除了$符号,然后控制台日志中显示的变量是&FG%@(*4Fgawq@)而不是$B&FG%@(*4Fgawq@)

Simply escaping the dollar sign will solve the issue.只需 escaping 美元符号即可解决问题。

The reason this has to be done is because otherwise, for $B , env-cmd will try to perform variable substitution on the variable B , which is empty and will resolve to an empty string.必须这样做的原因是,否则,对于$Benv-cmd将尝试对变量B执行变量替换,该变量为空并将解析为空字符串。

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

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