Cli: ENOENT packager.env when building RN from source during `react-native run-android`

Created on 25 Jan 2019  路  4Comments  路  Source: react-native-community/cli

Environment

$ react-native info

  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: (4) x64 Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
      Memory: 726.04 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.6.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.5.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
      Android SDK:
        API Levels: 19, 27, 28
        Build Tools: 27.0.3, 28.0.2
        System Images: android-19 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.1 AI-173.4819257
      Xcode: 9.4/9F1027a - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: git://github.com/jyrno42/react-native.git#bf64df4aea3f8ecda3fd9cfc2ed25e9f61ac905b => 1000.0.0
    npmGlobalPackages:
      react-native-cli: 2.0.1

Description

I have to manually create the directory node_modules/@react-native-community/cli/scripts to get the packager to start when using RN from source. Note, the issue only occurs when running react-native run-android.

Reproducible Demo

  1. Clone https://github.com/Jyrno42/rn-geoloctest
  2. yarn
  3. yarn android
  4. Get the following output:
$ yarn android
yarn run v1.12.3
$ react-native run-android
Starting JS server...

ENOENT: no such file or directory, open '/Users/me/Documents/projects/rn-geoloctest/node_modules/@react-native-community/cli/scripts/.packager.env'

Error: ENOENT: no such file or directory, open '/Users/me/Documents/projects/rn-geoloctest/node_modules/@react-native-community/cli/scripts/.packager.env'
    at Object.openSync (fs.js:450:3)
    at Object.writeFileSync (fs.js:1212:35)
    at startServerInNewWindow (/Users/me/Documents/projects/rn-geoloctest/node_modules/@react-native-community/cli/build/runAndroid/runAndroid.js:185:6)
    at isPackagerRunning.then.result (/Users/me/Documents/projects/rn-geoloctest/node_modules/@react-native-community/cli/build/runAndroid/runAndroid.js:77:7)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

error Command failed with exit code 1.
  1. Run mkdir node_modules/@react-native-community/cli/scripts
  2. Run yarn android again, packager now starts
bug

Most helpful comment

Yup. We want to fix this in next 2 weeks (see our "Next Release" project).

All 4 comments

Had the same issue, but creating the folder didn't work for me.
I believe is related to

where a lot of stuff that was in the main react-native repo was copied to the cli, but the scripts folder still in the main repo.

I tried to copy the scripts folder to node_modules/react-native/node_modules/@react-native-community/cli/ but error still happens.

But when I changed

https://github.com/react-native-community/react-native-cli/blob/2ff7ef9260f63c0d7e37401f57bd3d1ebd4597b4/packages/cli/src/runAndroid/runAndroid.js#L224

adding extra '..', to fix the path, it accessed the node_modules/react-native/scripts folder properly.

@grabbou Is there any planned schedule for that?

Yup. We want to fix this in next 2 weeks (see our "Next Release" project).

Ouch, this makes run-android totally broken. We are going to release a fix and include it in next RC.

Was this page helpful?
0 / 5 - 0 ratings