cli@7.0.2 fail to start - Cannot read property 'reportEvent' of undefined
See original GitHub issueEnvironment
System:
OS: macOS 12.2
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 168.50 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.18.1 - /var/folders/j4/nw3_c4nd029_zvtg_cy0k1d80000gn/T/yarn--1645213250030-0.5190764815852629/node
Yarn: 1.22.15 - /var/folders/j4/nw3_c4nd029_zvtg_cy0k1d80000gn/T/yarn--1645213250030-0.5190764815852629/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
Java: javac 13 - /usr/bin/javac
npmPackages:
@react-native-community/cli: ^7.0.2 => 7.0.2
react: 17.0.2 => 17.0.2
react-native: 0.68.0-rc.1 => 0.68.0-rc.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Description
Hi, I tried to init new project npx react-native init RN068RC1 --version 0.68.0-rc.1
but when I run yarn start
, it will throw this error:
error Cannot read property 'reportEvent' of undefined.
TypeError: Cannot read property 'reportEvent' of undefined
at Object.runServer [as func] (/Users/danielsuchy/javascript/RN068RC1/node_modules/@react-native-community/cli-plugin-metro/build/commands/start/runServer.js:131:38)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Command.handleAction (/Users/danielsuchy/javascript/RN068RC1/node_modules/@react-native-community/cli/build/index.js:192:9)
I tried this on my second computer with same result.
I figured out this hotfix for package.json
:
"resolutions": {
"@react-native-community/cli-server-api": "7.0.0",
}
Reproducible Demo
npx react-native init RN068RC1 --version 0.68.0-rc.1
Then try to run packager yarn start
.
// edit: replaced my hotfix by hotfix from @NickGerleman in case anyone else will encounter issue
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >ERROR in Cannot read property '0' of undefined after upgrade ...
In my situation, the error appeared after transferring classes to another file. VS code didn't show the error location. I had to open...
Read more >[1.0.0] TypeError: Cannot read properties of undefined ...
When you use default the method create return undefined, this is the reason of the error.
Read more >ERROR TypeError: Cannot read property title of undefined
HEY, SET YOUR LIKE THERE ! ... Your browser can't play this video. ... Solved: ERROR TypeError: Cannot read property title of undefined....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup, @NickGerleman got this pretty much right 😄 What I can add from myself is I figured a manual “quick fix” should be good enough for this “simple” change (because there are only 2 packages and I’d need to generate artificial changes in the packages for Lerna change engine to kick in and I had many issues with Lerna detect changes and publish in the past).
This, in retrospect obviously, wasn’t a good idea, as I forgot to build the packages before publishing (lerna does that) and needed to publish yet another version for 6.x. What’s more, this caused
cli
to yet again depend on a 6.x version ofcli-server-api
, which was just reverted to not include the breaking change, and I didn’t notice it, huh 😅. All of that on a Friday evening. enter what a week captain meme .So now I updated all the necessary packages to 7.0.3 through Lerna, and it should be all good. Trust your tools folks.
@NickGerleman Thanks for exhausting explanation, I am always curios about how these things happen.