Init does not work with yarn workspaces
envgap__react-native-community__cli-277
Original GitHub issue ↗Opened 2019-03-29
01 / FAILURE SIGNATURE
As reported upstream
Error: Cannot find module '/home/gabriel/keepfy/root/packages/KeepfyApp/node_modules/react-native/package.json'
Not a benchmark task.
- No curated issue-specific recipe or verified environment fix is available.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
package.json- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
react-native-community/cli #277 · read the original issue
Copy from https://github.com/facebook/react-native/issues/24202 and there's a related issue https://github.com/react-native-community/react-native-cli/issues/271
## 🐛 Bug Report
I'm using `react-native init` to create a simple app inside a monorepo, but the cli seems to have problems with the yarn workspaces (with hoisting) - I'm also using lerna, but i don't think that lerna is causing the problems here.
## To Reproduce
I'm just running:
`react-native init KeepfyApp`
The log is:
```
This will walk you through creating a new React Native project in /home/gabriel/keepfy/root/packages/KeepfyApp
Using yarn v1.15.2
Installing react-native...
yarn add v1.15.2
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
**========= SOME WARNINGS NOT INCLUDED HERE =========**
[4/4] Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
info All dependencies
└─ react-native@0.59.2
Done in 12.57s.
internal/modules/cjs/loader.js:651
throw err;
^
Error: Cannot find module '/home/gabriel/keepfy/root/packages/KeepfyApp/node_modules/react-native/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
at Function.Module._load (internal/modules/cjs/loader.js:575:25)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at checkNodeVersion (/home/gabriel/.fnm/node-versions/v11.12.0/installation/lib/node_modules/react-native-cli/index.js:306:21)
at run (/home/gabriel/.fnm/node-versions/v11.12.0/installation/lib/node_modules/react-native-cli/index.js:300:3)
at createProject (/home/gabriel/.fnm/node-versions/v11.12.0/installation/lib/node_modules/react-native-cli/index.js:249:3)
at init (/home/gabriel/.fnm/node-versions/v11.12.0/installation/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/home/gabriel/.fnm/node-versions/v11.12.0/installation/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:799:30)
```
The `Error: Cannot find module '/home/gabriel/keepfy/root/packages/KeepfyApp/node_modules/react-native/package.json'` is correct, there's no `node_modules` folder there, they are installed in the root folder, the correct path should be `/home/gabriel/keepfy/root/node_modules/react-native/package.json`
## Expected Behavior
I'm expecting the app to be created, but only the `package.json` is created.
## Code Example
```
// lerna.json
{
"packages": [
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent"
}
//package.json (root)
{
"name": "root",
"private": true,
"devDependencies": {
"lerna": "3.13.1",
"yarn": "1.15.2"
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build --stream",
"bootstrap": "lerna bootstrap"
}
}
```
Wit04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
Issue-specific recipe and runtime smoke command require review against the complete issue and repository.
Legacy reproduction is generic install-only; match the actual issue failure before admission.