File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
packages/create-react-native-library/src Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,28 @@ async function create(argv: yargs.Arguments<any>) {
151151 process . exit ( 1 ) ;
152152 }
153153
154+ try {
155+ const child = spawn ( 'npx' , [ '--help' ] ) ;
156+
157+ await new Promise ( ( resolve , reject ) => {
158+ child . once ( 'error' , reject ) ;
159+ child . once ( 'close' , resolve ) ;
160+ } ) ;
161+ } catch ( error ) {
162+ // @ts -expect-error: TS doesn't know about `code`
163+ if ( error != null && error . code === 'ENOENT' ) {
164+ console . log (
165+ `Couldn't find ${ kleur . blue (
166+ 'npx'
167+ ) } ! Please install it by running ${ kleur . blue ( 'npm install -g npx' ) } `
168+ ) ;
169+
170+ process . exit ( 1 ) ;
171+ } else {
172+ throw error ;
173+ }
174+ }
175+
154176 let name , email ;
155177
156178 try {
You can’t perform that action at this time.
0 commit comments