brodycj / create-react-native-module

MIT License
666 stars 52 forks source link

--generate-example fails #357

Open ggunti opened 4 years ago

ggunti commented 4 years ago

Hello! If I run create-react-native-module --generate-example MultiKeyboard for example, I get the following error regarding pod --version:

check for valid pod version in ./react-native-multi-keyboard/example/ios
pod --version failure, aborting with broken example app
Error while creating library module react-native-multi-keyboard
Error: Command failed with ENOENT: pod --version
spawnSync pod ENOENT
    at Object.spawnSync (internal/child_process.js:1041:20)
    at Object.spawnSync (child_process.js:616:24)
    at Function.module.exports.sync (/usr/local/lib/node_modules/create-react-native-module/node_modules/execa/index.js:169:25)
    at module.exports.commandSync (/usr/local/lib/node_modules/create-react-native-module/node_modules/execa/index.js:227:15)
    at /usr/local/lib/node_modules/create-react-native-module/lib/lib.js:278:17
    at new Promise (<anonymous>)
    at /usr/local/lib/node_modules/create-react-native-module/lib/lib.js:233:18
MacBook-Pro-Macbook:rn_projects macbook$ cd react-native-multi-keyboard/example/ios
-bash: cd: react-native-multi-keyboard/example/ios: No such file or directory
MacBook-Pro-Macbook:rn_projects macbook$ cd react-native-multi-keyboard/example/ios

In case that I do not use --generate-example, everything works, but I really need also an example project.

Thank you!

brodycj commented 4 years ago

Assuming that you are on a macOS host, you do have to install the pod tool before you can generate with an example app or generate any React Native app in general. I think the React Native CLI will offer to install pod for you but I like to install the tools myself. I am pretty sure I used Homebrew to install pod, which is my recommended solution.

I do think the error message should explain that the pod tool is missing and needs to be installed, already added the bug label. Thanks.

sajjad26 commented 4 years ago

I am having the same problem on macOS and I do have pod version 1.9.1 installed.

brodycj commented 4 years ago

I am having the same problem on macOS and I do have pod version 1.9.1 installed.

That does not sound right to me. Please do pod --version from your command line, show the results of pod --version, and show all relevant output for the error.

FYI I am at pod 1.8.4, will upgrade and try again when I get a chance.

sajjad26 commented 4 years ago

pod --version is 1.9.1

✖ Downloading template
error Error: Command failed: yarn add react-native@react-native@latest
error Couldn't find any versions for "react-native" that matches "react-native@latest"
yarn add v1.22.4
info No lockfile found.

And this

check for valid pod version in ./react-native-my-fancy-library/example/ios
pod --version failure, aborting with broken example app
Error while creating library module react-native-my-fancy-library
Error: Command failed with ENOENT: pod --version
spawnSync pod ENOENT
    at Object.spawnSync (internal/child_process.js:1041:20)
    at Object.spawnSync (child_process.js:616:24)
    at Function.module.exports.sync (/Users/sajjadashraf/.nvm/versions/node/v12.16.2/lib/node_modules/create-react-native-module/node_modules/execa/index.js:169:25)
    at module.exports.commandSync (/Users/sajjadashraf/.nvm/versions/node/v12.16.2/lib/node_modules/create-react-native-module/node_modules/execa/index.js:227:15)
    at /Users/sajjadashraf/.nvm/versions/node/v12.16.2/lib/node_modules/create-react-native-module/lib/lib.js:278:17
    at new Promise (<anonymous>)
brodycj commented 4 years ago

@sajjad26 it looks to me like you are hitting issue #312 before hitting the issue with pod, and I am now suspecting that the ENOENT error is because of the missing template.

zyestin commented 11 months ago

For me, use --example-react-native-template react-native@0.62, everything works