Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
feat: use process.env.METRO_NODE_OPTIONS when starting Metro
Browse files Browse the repository at this point in the history
Instead of using NODE_OPTIONS from the expo-cli process, the Metro process overrides it with METRO_NODE_OPTIONS.

This has two effects: (1) the expo-cli process can be debugged with --inspect-brk without causing an "address already in use" error in the Metro process,
and (2) the Metro process can be debugged with --inspect-brk.
  • Loading branch information
aleclarson committed Jul 26, 2020
1 parent e70433b commit d886d5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/xdl/src/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1796,9 +1796,12 @@ export async function startReactNativeServerAsync(

if (options.reset) {
cliOpts.push('--reset-cache');
} // Get custom CLI path from project package.json, but fall back to node_module path
}

// Get custom CLI path from project package.json, but fall back to node_module path
const defaultCliPath = resolveModule('react-native/local-cli/cli.js', projectRoot, exp);
const cliPath = exp.rnCliPath || defaultCliPath;

let nodePath;
// When using a custom path for the RN CLI, we want it to use the project
// root to look up config files and Node modules
Expand All @@ -1807,15 +1810,18 @@ export async function startReactNativeServerAsync(
} else {
nodePath = null;
}

// Run the copy of Node that's embedded in Electron by setting the
// ELECTRON_RUN_AS_NODE environment variable
// Note: the CLI script sets up graceful-fs and sets ulimit to 4096 in the
// child process
const nodePathEnv = nodePath ? { NODE_PATH: nodePath } : {};

const packagerProcess = child_process.fork(cliPath, cliOpts, {
cwd: projectRoot,
env: {
...process.env,
NODE_OPTIONS: process.env.METRO_NODE_OPTIONS,
REACT_NATIVE_APP_ROOT: projectRoot,
ELECTRON_RUN_AS_NODE: '1',
...nodePathEnv,
Expand Down

0 comments on commit d886d5f

Please sign in to comment.