如何同时使用 npm 包或一个命令运行 React 并激活 python virtualenv

问题描述 投票:0回答:1

我正在尝试创建一个 npm run 脚本,它可以启动 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
脚本 run React 并给出以下错误:

[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:\Work\movielust\frontend\public
[0] i 「wds」: 404s will fallback to /
[0] Starting the development server...

我的目录结构是:

main
|___frontend
|   |___package.json
|___backend
|   |___env
|   |___src
|       |___app.py

是否有任何解决方法,或者这实际上不可能,或者是否有其他方法可以同时运行 React 和 Flask?

python npm virtualenv npm-scripts concurrently
1个回答
-1
投票

你好@Anurag,你找到解决方案了吗?我正在尝试将 nextjs 与 Flask 一起使用,并面临与虚拟环境未运行相同的问题

© www.soinside.com 2019 - 2024. All rights reserved.