undefined is not an object when used in a React Native project.
See original GitHub issueHello,
I’m messing around with React Native and I wanted to try using chalk to help make some of the logs more clear. I’m running into an issue though at the import/require step.
If I try import chalk from 'chalk';
or const chalk = require('chalk');
I receive the following error:
Here are the output of the React Packager:
[12/28/2016, 3:59:04 PM] <START> Requesting bundle bundle_url: /index.ios.bundle?platform=ios&dev=true&minify=false
[12/28/2016, 3:59:04 PM] <END> Requesting bundle bundle_url: /index.ios.bundle?platform=ios&dev=true&minify=false (25ms)
[12/28/2016, 3:59:04 PM] <START> Symbolicating
[12/28/2016, 3:59:04 PM] <END> Symbolicating (319ms)
[12/28/2016, 3:59:04 PM] <START> Symbolicating
[12/28/2016, 3:59:05 PM] <END> Symbolicating (306ms)
If I’m following the stack trace correctly its complaining about lines 2-4 in supports-color/index.js:
var argv = process.argv;
var terminator = argv.indexOf('--');
Further info: OS: OSX v10.11.6 Node: v5.9.1 NPM: v3.10.8 React Native: v0.39.2 Chalk: v^1.1.3
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Getting undefined is not an object in React native when ...
First, the prop you pass to RenderPhotos is this.props.photos , which is undefined in AwesomeProject . Looking in the render() function of ...
Read more >TypeError: undefined is not an object – React - DPS Computing
Simply, you're treating a variable like it is an object when it is not. 'undefined' means that your variable hasn't yet been defined...
Read more >Render Error undefined is not an Object (evaluating _react ...
Render Error undefined is not an Object (evaluating _react.react .createElement) Fixed- React Native.
Read more >undefined is not an object (evaluating 'device.id') in ... - YouTube
How to Add Apollo Client to React Native | React Native Tutorial · ERROR TypeError: undefined is not an object (evaluating '_reactNative. ·...
Read more >ERROR TypeError: undefined is not an object (evaluating ...
Ever encountered this error → ERROR TypeError: undefined is not an object (evaluating '_this.props.navigation.navigate') whilst working hard on your project?
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
Well
process.argv
is going to be your first of several problems. We also check the environment (which may not exist either), and specifically the$TERM
env variable. You’re going to have to emulate those if you want to do any of that.Chalk is really for terminal emulators (console, terminals, etc.). If you’re not running on one of those, Chalk isn’t really going to help you much.
Ran into this when trying to use Chalk with
FORCE_COLOR
while logging in React Native. sindresorhus/has-flag#3 suggests that React Native should provide aprocess.argv
.