renative icon indicating copy to clipboard operation
renative copied to clipboard

When running a ReNative project I receive an error: 'Cannot find module 'react-native/package.json''

Open KarlOstMod opened this issue 2 years ago • 4 comments

Describe the bug When running a ReNative project I receive an error: 'Cannot find module 'react-native/package.json''

To Reproduce Steps to reproduce the behaviour

  1. Run command 'rnv'
  • select new
  • project name 'evaluation'
  • project title 'evaluation'
  • app id select the default (com.mycompany.evaluation)
  • version select the default (0.1.0)
  • workspace 'rnv'
  • template '@rnv/template-starter'
  • what template '0.36.1 (HEAD: latest)'
  • what platforms would you like to use - use default (all)
  • set up git 'no'
  1. cd into 'evaluation' folder
  2. run 'rnv run'

Expected behavior RNV projects bootstrapped and ready to develop with with no error.

Screenshots or copy&paste If applicable, add screenshots to help explain your problem. If applicable, copy&paste the output of the command. Run the command with -i to get more debugging informations

┌──────────────────────────────────────────────────────────────────────────────┐ │ 🚀 ReNative Project Generator │ │ │ ├──────────────────────────────────────────────────────────────────────────────┤ │ │ │ Project Name (folder): evaluation │ │ Workspace: rnv │ ? ┌──────────────────────────────────────────────────────────────────────────────┐ │ 🚀 ReNative Project Generator │ │ │ ├──────────────────────────────────────────────────────────────────────────────┤ │ │ │ Project Name (folder): evaluation │ │ Workspace: rnv │ ? ┌──────────────────────────────────────────────────────────────────────────────┐ │ 🚀 ReNative Project Generator │ │ │ ├──────────────────────────────────────────────────────────────────────────────┤ │ │ │ Project Name (folder): evaluation │ │ Workspace: rnv │ │ Project Title: evaluation │ │ Project Version: 0.1.0 │ │ App ID: com.mycompany.evaluation │ │ Project Template: @rnv/[email protected] │ │ Git Enabled: false │ │ │ │ Project Platforms: │ │ ios, android, androidtv, firetv, androidwear, web, webtv, tizen, │ │ tvos, webos, macos, windows, tizenwatch, tizenmobile, kaios, │ │ firefoxos, firefoxtv, chromecast, xbox │ │ │ │ Project Structure: │ │ │ │ evaluation │ │ ├── appConfigs # Application flavour configuration files/assets │ │ │ └── [APP_ID] # Example application flavour │ │ │ ├── assets # Platform assets injected to ./platformAssets │ │ │ ├── builds # Platform files injected to ./platformBuilds │ │ │ ├── fonts # Folder for all custom fonts │ │ │ ├── plugins # Multi-platform plugins injections │ │ │ └── renative.json # Application flavour config │ │ ├── platformAssets # Generated cross-platform assets │ │ ├── platformBuilds # Generated platform app projects │ │ ├── src # Source code files │ │ ├── index.*.js # Entry files │ │ └── renative.json # ReNative project configuration │ │ │ └──────────────────────────────────────────────────────────────────────────────┘

Error:

│ [ error ] Cannot find module 'react-native/package.json' Require stack:

  • /home/karl/rn/evaluation/node_modules/@react-native-windows/cli/lib-commonjs/healthChecks.js
  • /home/karl/rn/evaluation/node_modules/@react-native-windows/cli/lib-commonjs/index.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/sdks/sdk-windows/index.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/sdks/index.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/tasks/task.rnv.build.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/index.js
  • /usr/local/lib/node_modules/rnv/dist/core/engineManager/index.js
  • /usr/local/lib/node_modules/rnv/dist/core/runtimeManager/index.js
  • /usr/local/lib/node_modules/rnv/dist/cli/index.js
  • /usr/local/lib/node_modules/rnv/dist/index.js
  • /usr/local/lib/node_modules/rnv/bin/index.js Error: Cannot find module 'react-native/package.json' Require stack:
  • /home/karl/rn/evaluation/node_modules/@react-native-windows/cli/lib-commonjs/healthChecks.js
  • /home/karl/rn/evaluation/node_modules/@react-native-windows/cli/lib-commonjs/index.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/sdks/sdk-windows/index.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/sdks/index.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/tasks/task.rnv.build.js
  • /home/karl/rn/evaluation/node_modules/@rnv/engine-rn-windows/dist/index.js
  • /usr/local/lib/node_modules/rnv/dist/core/engineManager/index.js
  • /usr/local/lib/node_modules/rnv/dist/core/runtimeManager/index.js
  • /usr/local/lib/node_modules/rnv/dist/cli/index.js
  • /usr/local/lib/node_modules/rnv/dist/index.js
  • /usr/local/lib/node_modules/rnv/bin/index.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.resolve (node:internal/modules/cjs/helpers:108:19) at Object. (/home/karl/rn/evaluation/node_modules/@react-native-windows/cli/src/healthChecks.ts:5:36) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at Module.patchedRequire [as require] (/home/karl/rn/evaluation/node_modules/diagnostic-channel/dist/src/patchRequire.js:14:46) at require (node:internal/modules/cjs/helpers:102:18)

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.4 LTS
  • Node Version v16.14.0
  • RNV Version 0.36.1

KarlOstMod avatar Jul 15 '22 12:07 KarlOstMod

@KarlOstMod I can't seem to be able to replicate this issue on osx. You're getting this while creating the project, not while trying to actually run it, correct? I'll roll out an Ubuntu VM to test it there as well.

mihaiblaga89 avatar Jul 19 '22 11:07 mihaiblaga89

Hi @mihaiblaga89 . I can and my colleague can recreate on OSX.

I'm using: node v18.3.0 op: macOS Monterey npm: 8.14.0

the error occurs after cd'ing into the directory and running rnv run

 [ error ] Cannot find module 'react-native/package.json'
Require stack:
- /Users/karl.prior/Documents/rn/test/node_modules/@react-native-windows/cli/lib-commonjs/healthChecks.js
- /Users/karl.prior/Documents/rn/test/node_modules/@react-native-windows/cli/lib-commonjs/index.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/sdks/sdk-windows/index.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/sdks/index.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/tasks/task.rnv.build.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/core/engineManager/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/core/runtimeManager/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/cli/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/index.js
- /opt/homebrew/lib/node_modules/rnv/bin/index.js
Error: Cannot find module 'react-native/package.json'
Require stack:
- /Users/karl.prior/Documents/rn/test/node_modules/@react-native-windows/cli/lib-commonjs/healthChecks.js
- /Users/karl.prior/Documents/rn/test/node_modules/@react-native-windows/cli/lib-commonjs/index.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/sdks/sdk-windows/index.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/sdks/index.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/tasks/task.rnv.build.js
- /Users/karl.prior/Documents/rn/test/node_modules/@rnv/engine-rn-windows/dist/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/core/engineManager/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/core/runtimeManager/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/cli/index.js
- /opt/homebrew/lib/node_modules/rnv/dist/index.js
- /opt/homebrew/lib/node_modules/rnv/bin/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.<anonymous> (/Users/karl.prior/Documents/rn/test/node_modules/@react-native-windows/cli/src/healthChecks.ts:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at Module.patchedRequire [as require] (/Users/karl.prior/Documents/rn/test/node_modules/diagnostic-channel/dist/src/patchRequire.js:14:46)
    at require (node:internal/modules/cjs/helpers:102:18)

KarlOstMod avatar Jul 19 '22 11:07 KarlOstMod

Hi @mihaiblaga89. It works if I only select web and cd into the dir and rnv run.

KarlOstMod avatar Jul 19 '22 12:07 KarlOstMod

@KarlOstMod oh, ok. I was now able to replicate the issue. You can create a project normally (with all the platforms) and then instead of rnv run do rnv run -p <platform> while I'm working on a fix for the guided part.

mihaiblaga89 avatar Jul 19 '22 15:07 mihaiblaga89

Was fixed and not reproduced on 0.37.1

pauliusguzas avatar Aug 08 '23 11:08 pauliusguzas