Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'on' of undefined #182

Closed
cliren opened this issue Apr 25, 2017 · 9 comments
Closed

TypeError: Cannot read property 'on' of undefined #182

cliren opened this issue Apr 25, 2017 · 9 comments
Labels
moving-to-expo-cli The issue tracker has been moved to expo/expo-cli. Please file bugs in the Expo CLI repository now. no idea

Comments

@cliren
Copy link

cliren commented Apr 25, 2017

Description

  1. Created a brand new project following instructions at https://facebook.github.io/react-native/blog/2017/03/13/introducing-create-react-native-app.html
  2. First time the project ran fine using npm run ios, launched iOS simulator with the example page
  3. Ctrl+C from the terminal running Setup CI? #2 above
  4. Run npm run ios, got the below error

Expected Behavior

See above steps

Observed Behavior

Error occurred running npm run ios the second time

ps.stdout.on('data', function (data) {
             ^
TypeError: Cannot read property 'on' of undefined
    at buildProcessTree (/Users/gbacrna_sample/run_ios_error/node_modules/tree-kill/index.js:78:14)
    at /Users/gbacrna_sample/run_ios_error/node_modules/tree-kill/index.js:99:11
    at Array.forEach (native)
    at ChildProcess.onClose (/Users/gbacrna_sample/run_ios_error/node_modules/tree-kill/index.js:94:31)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:501:12)
/Users/gbacrna_sample/run_ios_error/node_modules/tree-kill/index.js:78
    ps.stdout.on('data', function (data) {
             ^

TypeError: Cannot read property 'on' of undefined
    at buildProcessTree (/Users/gbacrna_sample/run_ios_error/node_modules/tree-kill/index.js:78:14)
    at module.exports (/Users/gbacrna_sample/run_ios_error/node_modules/tree-kill/index.js:18:9)
    at process.<anonymous> (/xdl/src/Project.js:683:5)
    at emitOne (events.js:96:13)
    at process.emit (events.js:188:7)
    at process.emit (/Users/gbacrna_sample/run_ios_error/node_modules/source-map-support/source-map-support.js:430:21)
    at process.exit (internal/process.js:147:15)
    at printErrorAndExit (/Users/gbacrna_sample/run_ios_error/node_modules/source-map-support/source-map-support.js:414:11)
    at process.emit (/Users/gbacrna_sample/run_ios_error/node_modules/source-map-support/source-map-support.js:426:16)
    at process._fatalException (bootstrap_node.js:284:26)

Environment

Please run these commands in the project folder and fill in their results:

npm ERR! peer dep missing: react@>=15.3.1, required by [email protected]
npm ERR! peer dep missing: react@>=15.4.0, required by [email protected]
npm ERR! peer dep missing: react@>=15.4.0, required by [email protected]

  • node -v:v7.0.0
  • npm -v:3.10.8
  • yarn --version: using npm
  • watchman version:"4.7.0"

Also specify:

  1. Operating system: OSX
  2. Phone/emulator/simulator & version: ios simulator 7

Reproducible Demo

https://github.com/cliren/crna_sample

@anp
Copy link
Contributor

anp commented Apr 25, 2017

Hi! Thanks for the detailed report!

I'm not able to reproduce this on a fairly similar environment, so I suspect some local state is at play. Could you please try deleting your project's .expo folder and trying this again? It's used to store some information about the packager process while it's running and seems like it may have been written to incorrectly.

@cliren
Copy link
Author

cliren commented Apr 25, 2017

Removing .expo worked after a second try (didn't work for the first time), thanks for your quick tip! Its much faster to run 'npm run ios' then running the whole thing in XDE. The error in question pops up as soon Ctrl+C, there is some background process not liking it!

@cliren cliren closed this as completed Apr 25, 2017
@ickma
Copy link

ickma commented Jul 18, 2017

rm -rf .expo really solved my problem,but I need to do this everytime if I want to quit exp,and ,I found I can't use exp ba or exp bi to build standalone apps,all the same issue as @cliren

@brentvatne
Copy link
Member

@ickma - can you give some information about your environment? I've never seen this problem before.

  • node -v:
  • npm -v:
  • yarn --version:
  • watchman version:
  • Operating system:

@davidhellsing
Copy link

davidhellsing commented Aug 21, 2017

@brentvatne I got the same issue when crtl-c after running the packager:

screen shot 2017-08-21 at 09 59 27

  • Node v6.8.1
  • NPM 4.1.2
  • Yarn 0.21.3
  • Watchman 4.7.0
  • OSX Sierra 10.12.3

yarn start yields the same error after this, until I run rm -rf .expo

This is from a clean React Native project following the basic tutorial from scratch.

@lmumar
Copy link

lmumar commented Aug 29, 2017

Same issue as @davidhellsing, pressing ctrl-c will show the error. I also tried deleting my node_modules folder and reinstall everything but the error still shows up. I have to delete the .expo file every time I do development.

  • Node v7.10.1
  • NPM v4.2.0
  • OSX Sierra

@anp anp reopened this Aug 29, 2017
@bceskavich
Copy link

bceskavich commented Oct 22, 2017

I'm running into this issue on a recently created project. Error outputs look like those shared by @davidhellsing. This project is being run on two machines. The issue affects one machine, but not the other. The setups look like:

Machine 1 (shutdown errors present)

Machine 2 (no shutdown errors)

I'm wondering if any of the differentiating factors b/t these two machines (yarn presence, use of nvm, macOS version, watchman) are significant?

(edited to provide more detail about watchman install differences)

@brentvatne
Copy link
Member

we can't repro this. if someone who has a repro case can clone the repo and experiment with fixing it that would be much appreciated

@darkrishabh
Copy link

darkrishabh commented Mar 11, 2018

Just a hacky way, not sure if this is a fix. In tree-kill module - index.js change in the onClose method.
the module will be in /exp/node_modules/tree-kill/index.js - L.N = 91

change:

if (code != 0) {
to:
if (code == 0) {
And everything works.

@fson fson added the moving-to-expo-cli The issue tracker has been moved to expo/expo-cli. Please file bugs in the Expo CLI repository now. label Oct 3, 2018
@fson fson closed this as completed Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moving-to-expo-cli The issue tracker has been moved to expo/expo-cli. Please file bugs in the Expo CLI repository now. no idea
Projects
None yet
Development

No branches or pull requests

9 participants