部署Plaid银行教程Docker镜像时遇REACT_APP_API_HOST命令未识别错误
问题解决:'REACT_APP_API_HOST' is not recognized as an internal or external command
错误原因
你在Windows PowerShell中运行Makefile时触发的错误,根源是Makefile使用了Unix shell专属的环境变量前置语法(VAR=value command),但Windows的PowerShell/CMD不支持这种写法,会把REACT_APP_API_HOST=http://python:8000当成独立命令执行,导致识别失败。
解决方案
以下三种方法任选其一即可解决问题:
方法1:修改Makefile适配Windows语法
将Makefile中up目标的环境变量赋值改为Windows CMD兼容格式:
.PHONY: up up: set "REACT_APP_API_HOST=http://$(language):8000" && \ $(DOCKER_COMPOSE) \ $(DOCKER_COMPOSE_YML) \ $@ --build --detach --remove-orphans \ $(language) @echo $(SUCCESS_MESSAGE)
核心是用set "VAR=value" &&替代Unix的VAR=value 语法,确保Windows shell能正确识别环境变量赋值。
方法2:使用WSL(Windows子系统Linux)运行
直接在WSL终端中执行所有教程命令:
git clone -c core.symlinks=true https://github.com/plaid/quickstart cd quickstart cp .env.example .env # 编辑.env填写PLAID_CLIENT_ID和PLAID_SECRET make up language=python
WSL使用Unix shell,完全兼容原Makefile语法,无需修改任何配置。
方法3:将环境变量写入.env文件
把REACT_APP_API_HOST直接添加到项目的.env文件中:
# .env文件新增一行 REACT_APP_API_HOST=http://python:8000
然后修改Makefile,去掉环境变量前置的行:
.PHONY: up up: $(DOCKER_COMPOSE) \ $(DOCKER_COMPOSE_YML) \ $@ --build --detach --remove-orphans \ $(language) @echo $(SUCCESS_MESSAGE)
Docker Compose会自动读取.env文件中的变量,无需在命令行手动传递。
内容的提问来源于stack exchange,提问作者kubjasp
相关产品推荐
相关产品推荐

