Skip to content

Commit 63c0a99

Browse files
fix: do not block run-ios/android when failed to start packager (#2252)
1 parent 13e3735 commit 63c0a99

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/cli-tools/src/startServerInNewWindow.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import path from 'path';
22
import fs from 'fs';
33
import execa from 'execa';
4-
import {CLIError} from './errors';
54
import resolveNodeModuleDir from './resolveNodeModuleDir';
65
import logger from './logger';
6+
import chalk from 'chalk';
7+
8+
const ERROR = `a dev server manually by running ${chalk.bold(
9+
'npm start',
10+
)} or ${chalk.bold('yarn start')} in other terminal window.`;
711

812
function startServerInNewWindow(
913
port: number,
@@ -12,9 +16,11 @@ function startServerInNewWindow(
1216
terminal?: string,
1317
) {
1418
if (!terminal) {
15-
throw new CLIError(
16-
'Cannot start server in new window because no terminal app was specified.',
19+
logger.error(
20+
'Cannot start server in new windows because no terminal app was specified, use --terminal to specify, or start ' +
21+
ERROR,
1722
);
23+
return;
1824
}
1925

2026
/**
@@ -73,10 +79,12 @@ function startServerInNewWindow(
7379
);
7480
}
7581
} catch (error) {
76-
return new CLIError(
77-
`Couldn't copy the script for running bundler. Please check if the "${scriptFile}" file exists in the "node_modules/@react-native-community/cli-tools" folder and try again.`,
82+
logger.error(
83+
`Couldn't copy the script for running bundler. Please check if the "${scriptFile}" file exists in the "node_modules/@react-native-community/cli-tools" folder, or start ` +
84+
ERROR,
7885
error as any,
7986
);
87+
return;
8088
}
8189

8290
if (process.platform === 'darwin') {
@@ -109,8 +117,10 @@ function startServerInNewWindow(
109117
stdio: 'ignore',
110118
});
111119
}
120+
112121
logger.error(
113-
`Cannot start the packager. Unknown platform ${process.platform}`,
122+
`Cannot start the packager. Unknown platform ${process.platform}. Try starting ` +
123+
ERROR,
114124
);
115125
return;
116126
}

0 commit comments

Comments
 (0)