我正在尝试创建一个npm运行脚本,该脚本可以启动react应用程序,然后激活python虚拟环境来运行flask服务器。
package.json:中的脚本
{
"scripts": {
"start": "react-scripts start",
"both": "concurrently "react-scripts start" "cd ../backend && "env/scripts/activate" && py src/app.py"",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
}
上面我使用的是concurrently
。但是执行both
脚本运行会产生反应并给出以下错误:
[1] 'env' is not recognized as an internal or external command,
[1] operable program or batch file.
[1] cd ../backend && env/scripts/activate && py src/app.py exited with code 1
[0] i 「wds」: Project is running at http://192.168.137.1/
[0] i 「wds」: webpack output is served from
[0] i 「wds」: Content not from webpack is served from D:Workmovielustfrontendpublic
[0] i 「wds」: 404s will fallback to /
[0] Starting the development server...
我的目录结构是:
main
|___frontend
| |___package.json
|___backend
| |___env
| |___src
| |___app.py
有没有解决这个或这个不可能的方法,或者有没有其他方法可以一次性运行反应器和烧瓶?
- 运行您的虚拟环境
- 不要试图从package.json中的脚本中更改路径或激活virtualenv
"scripts":
"flask-dev": "pip install -r requirements.txt && python -m flask --app api/index run -p 5328 --reload",
"next-dev": "next dev",
"dev": "concurrently "pnpm run next-dev" "pnpm run flask-dev"",
然后运行npm运行dev,它将从中获取环境和包…