|
17 | 17 | from redis.exceptions import RedisError |
18 | 18 |
|
19 | 19 | from reflex import constants |
| 20 | +from reflex.config import environment |
20 | 21 | from reflex.utils import console, path_ops, prerequisites |
21 | 22 |
|
22 | 23 |
|
@@ -156,24 +157,30 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs): |
156 | 157 | Raises: |
157 | 158 | Exit: When attempting to run a command with a None value. |
158 | 159 | """ |
159 | | - node_bin_path = str(path_ops.get_node_bin_path()) |
160 | | - if not node_bin_path and not prerequisites.CURRENTLY_INSTALLING_NODE: |
161 | | - console.warn( |
162 | | - "The path to the Node binary could not be found. Please ensure that Node is properly " |
163 | | - "installed and added to your system's PATH environment variable or try running " |
164 | | - "`reflex init` again." |
165 | | - ) |
| 160 | + # Check for invalid command first. |
166 | 161 | if None in args: |
167 | 162 | console.error(f"Invalid command: {args}") |
168 | 163 | raise typer.Exit(1) |
169 | | - # Add the node bin path to the PATH environment variable. |
| 164 | + |
| 165 | + path_env: str = os.environ.get("PATH", "") |
| 166 | + |
| 167 | + # Add node_bin_path to the PATH environment variable. |
| 168 | + if not environment.REFLEX_BACKEND_ONLY.get(): |
| 169 | + node_bin_path = str(path_ops.get_node_bin_path()) |
| 170 | + if not node_bin_path and not prerequisites.CURRENTLY_INSTALLING_NODE: |
| 171 | + console.warn( |
| 172 | + "The path to the Node binary could not be found. Please ensure that Node is properly " |
| 173 | + "installed and added to your system's PATH environment variable or try running " |
| 174 | + "`reflex init` again." |
| 175 | + ) |
| 176 | + path_env = os.pathsep.join([node_bin_path, path_env]) |
| 177 | + |
170 | 178 | env: dict[str, str] = { |
171 | 179 | **os.environ, |
172 | | - "PATH": os.pathsep.join( |
173 | | - [node_bin_path if node_bin_path else "", os.environ["PATH"]] |
174 | | - ), # type: ignore |
| 180 | + "PATH": path_env, |
175 | 181 | **kwargs.pop("env", {}), |
176 | 182 | } |
| 183 | + |
177 | 184 | kwargs = { |
178 | 185 | "env": env, |
179 | 186 | "stderr": None if show_logs else subprocess.STDOUT, |
|
0 commit comments