frostney / react-native-create-library

:notebook: Command line tool to create a React Native library with a single command
MIT License
1.45k stars 114 forks source link

--generate-example does not work with no yarn installed #97

Open brodycj opened 5 years ago

brodycj commented 5 years ago

Followup to #63 / #75:

If I would install this project as follows:

npm i -g https://github.com/frostney/react-native-create-library

then try generating a library project with --generate-example with no yarn installed:

react-native-create-library --prefix CT --package-identifier com.test --generate-example ModuleTest

it ends up with error messages:

> example@0.0.1 postinstall /Users/brodybits/Documents/bb/ct1/react-native-module-test/example
> node ../scripts/examples_postinstall.js node_modules/react-native-module-test

No node_modules path found at /Users/brodybits/Documents/bb/ct1/react-native-module-test/example/node_modules/react-native-module-test/node_modules. Skipping delete.
Deleting: /Users/brodybits/Documents/bb/ct1/react-native-module-test/example/node_modules/react-native-module-test/example
Error deleting /Users/brodybits/Documents/bb/ct1/react-native-module-test/example/node_modules/react-native-module-test/example: ENOENT: no such file or directory, lstat '/Users/brodybits/Documents/bb/ct1/react-native-module-test/example/node_modules/react-native-module-test/example/node_modules/react-proxy'
npm WARN react-native-module-test@1.0.0 requires a peer of react@16.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-module-test@1.0.0 requires a peer of react-native@^0.52.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-module-test@1.0.0 requires a peer of react-native-windows@0.52.0 but none is installed. You must install peer dependencies yourself.

audited 179259 packages in 64.447s
found 0 vulnerabilities

Command `link` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
Error while creating library ModuleTest
Error: Command failed: react-native link
    at checkExecSyncError (child_process.js:616:11)
    at execSync (child_process.js:653:13)
    at Promise (/Users/brodybits/.nvs/node/10.15.1-ct1/x64/lib/node_modules/react-native-create-library/lib.js:136:13)
    at new Promise (<anonymous>)
    at exec.then.then (/Users/brodybits/.nvs/node/10.15.1-ct1/x64/lib/node_modules/react-native-create-library/lib.js:119:18)

This does not seem to be intentional: https://github.com/frostney/react-native-create-library/blob/70762697b982515de03e335173de5b814f3b8717/lib.js#L133-L134

I wouldn't mind if this would be solved by explicitly requiring yarn to support the --generate-example flag.