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

[0.18-rc][packager] Packager throws error "Cannot read property 'error' of null" instead of babel errors #5191

Closed
corbt opened this issue Jan 7, 2016 · 32 comments

Comments

@corbt
Copy link
Contributor

@corbt corbt commented Jan 7, 2016

This is to track the error first reported in #5188 and #5190. (The thread in #5188 got long because we weren't sure if it was related to the simultaneous but unrelated babel classProperties syntax change, so I'm consolidating here.)

There's a regression in the packager in 0.18-rc where babel syntax errors aren't passed through to the user, making it difficult to fix the underlying bugs. These are the error messages for the same bug running react-native bundle:

React Native 0.17

uncaught error Error: SyntaxError: /Users/kyle/proj/chimera/app/actions/auth.js: 'import' and 'export' may only appear at the top level (22:0)
  20 |
  21 |
> 22 | export function logOut() {
     | ^
  23 |   return {type: LOG_OUT};
  24 | }

React Native 0.18-rc

uncaught error Error: TypeError: Cannot read property 'error' of null
    at index.js:117:20
    at tryCallOne (/Users/kyle/proj/chimera/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/kyle/proj/chimera/node_modules/react-native/node_modules/promise/lib/core.js:123:15
    at flush (/Users/kyle/proj/chimera/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:428:9)
TransformError: /Users/kyle/proj/chimera/app/actions/auth.js: Cannot read property 'error' of null
See logs /var/folders/j4/wct0sgyx0p9803_1nkhm3pzm0000gn/T/react-packager.log
    at SocketClient._handleMessage (SocketClient.js:139:23)
    at BunserBuf.<anonymous> (SocketClient.js:53:42)
    at emitOne (events.js:77:13)
    at BunserBuf.emit (events.js:169:7)
    at BunserBuf.process (/Users/kyle/proj/chimera/node_modules/react-native/node_modules/bser/index.js:289:10)
    at /Users/kyle/proj/chimera/node_modules/react-native/node_modules/bser/index.js:244:12
    at doNTCallback0 (node.js:428:9)
    at process._tickCallback (node.js:357:13)
@facebook-github-bot

This comment has been minimized.

Copy link

@facebook-github-bot facebook-github-bot commented Jan 7, 2016

Hey corbt, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!
@ide

This comment has been minimized.

Copy link
Contributor

@ide ide commented Jan 7, 2016

cc @martinbigio, it looks like the packager has an error while trying to report errors.

@corbt

This comment has been minimized.

Copy link
Contributor Author

@corbt corbt commented Jan 7, 2016

For what it's worth I just tested running with the same syntax error on master and the babel error message appeared correctly, so it looks like this has already been fixed. It's probably just a question of figuring out what to cherry-pick into the 0.18 branch.

@satya164

This comment has been minimized.

Copy link
Contributor

@satya164 satya164 commented Jan 8, 2016

Also I recently noticed that packager no longer reports errors when it fails to import/require a module.

@floatinghotpot

This comment has been minimized.

Copy link

@floatinghotpot floatinghotpot commented Jan 8, 2016

I also encounter the same issue on react-native 0.18.0-rc.

It's very easy to re-produce it, just create a new project, react-native init HelloReact, open the ios project with xcode, just build, it will report exact the same error.

If change package.json the react-native version from 0.18.0-rc to 0.17.0, and update the node-modules/react-native by rm -rf node-modules; npm install;, open ios project with xcode, build again, now build pass.

So, it must be something wrong with react-native v0.18.0-rc.

@israelidanny

This comment has been minimized.

Copy link

@israelidanny israelidanny commented Jan 10, 2016

I'm getting the exact same error by updating react 0.17 to 0.18.0-rc

@mkonicek

This comment has been minimized.

Copy link
Contributor

@mkonicek mkonicek commented Jan 11, 2016

Looks like this is something we should fix asap, I'll ping @martinbigio about it.

@mkonicek

This comment has been minimized.

Copy link
Contributor

@mkonicek mkonicek commented Jan 11, 2016

Thanks so much for using the rc everyone!

@mkonicek mkonicek mentioned this issue Jan 11, 2016
7 of 11 tasks complete
@tdzl2003

This comment has been minimized.

Copy link
Contributor

@tdzl2003 tdzl2003 commented Jan 11, 2016

Maybe it's caused by .babelrc from module react-deep-force-update which is incompatible with babel 6.x

@martinbigio

This comment has been minimized.

Copy link
Contributor

@martinbigio martinbigio commented Jan 11, 2016

This was already fixed on master last week. We need to cherry pick 5a4ee0b :)

@chshouyu

This comment has been minimized.

Copy link

@chshouyu chshouyu commented Jan 11, 2016

thanks all, waiting for release.

@jinzhaoyu

This comment has been minimized.

Copy link

@jinzhaoyu jinzhaoyu commented Jan 12, 2016

When i upgrade react-native from 0.17.0 to 0.18.0-rc , I faced same problem , and i try to apply 5a4ee0b ,I got babel error about .babelrc.stage , see flow error info:

{"message":"TransformError: /Users/jinzhaoyu/Desktop/tt/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/node_modules/react-deep-force-update/lib/index.js: [BABEL] /Users/jinzhaoyu/Desktop/tt/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/node_modules/react-deep-force-update/lib/index.js: Unknown option: /Users/jinzhaoyu/Desktop/tt/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/node_modules/react-deep-force-update/.babelrc.stage","type":"TransformError","errors":[{}]}

my environment:

  1. React-Native: 0.18-rc
  2. node: 5.3.0
  3. npm: 2.14.15
  4. watchman: 4.3.0
@martinbigio

This comment has been minimized.

Copy link
Contributor

@martinbigio martinbigio commented Jan 12, 2016

@jinzhaoyu, the error you're getting is unrelated to this issue. The problem is that you have a .babelrc file on react-deep-force-update.Try removing that file. Also make sure you're using the latest version of that npm module as Dan Abramov recently released a new version upgrading that :)

@int64ago

This comment has been minimized.

Copy link

@int64ago int64ago commented Jan 14, 2016

+1, waiting for fixing, thx :-)

@corbt

This comment has been minimized.

Copy link
Contributor Author

@corbt corbt commented Jan 19, 2016

0.18 is out now and this problem has been fixed!

@corbt corbt closed this Jan 19, 2016
@int64ago

This comment has been minimized.

Copy link

@int64ago int64ago commented Jan 19, 2016

@corbt
Hi, I tried the 0.18.0, but it wasn't fixed.
And when I switch to 0.17.0, it works well.

@jinzhaoyu

This comment has been minimized.

Copy link

@jinzhaoyu jinzhaoyu commented Jan 19, 2016

The problem still exists in 0.18.0 ,when i execute 'bundle' command ,i got same as 0.18-rc error:

TransformError: /test/react-native/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/modules/index.js: [BABEL] /test/react-native/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/modules/index.js: Unknown option: /test/react-native/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/.babelrc.stage

@tdzl2003

This comment has been minimized.

Copy link
Contributor

@tdzl2003 tdzl2003 commented Jan 19, 2016

Still need to remove .babelrc manually.

@corbt

This comment has been minimized.

Copy link
Contributor Author

@corbt corbt commented Jan 19, 2016

@int64ago that looks like a different bug. It does look like you're running into some kind of trouble though, do you run into that error on a fresh project?

@jinzhaoyu this is also a different bug, notice that the error message is different. Would you mind opening a new issue with steps to reproduce? It looks like it may be related to #5040 but that should be fixed. For now you can remove the offending /test/react-native/node_modules/react-native/node_modules/react-transform-hmr/node_modules/react-proxy/.babelrc file like @tdzl2003 said which should unblock you.

@int64ago

This comment has been minimized.

Copy link

@int64ago int64ago commented Jan 19, 2016

It's the same bug as #5259 which referenced by this issue.
And it's a fresh project.

@corbt

This comment has been minimized.

Copy link
Contributor Author

@corbt corbt commented Jan 19, 2016

From #5259:

if you go to http://localhost:8081/index.android.bundle?platform=android&dev=true in your browser...does it spit out JS? Or an error?

Can you do that and tell me what you see?

@int64ago

This comment has been minimized.

Copy link

@int64ago int64ago commented Jan 19, 2016

Almost the same as:

{
  message: "TransformError: /Users/patscanlan/repos/AwesomeProject/index.android.js: Cannot read property 'error' of null",
  type: "TransformError",
  errors: [{ }]
}
@corbt

This comment has been minimized.

Copy link
Contributor Author

@corbt corbt commented Jan 19, 2016

Ok try the following from the command line and post back the response here:

react-native bundle --entry-file=/Users/patscanlan/repos/AwesomeProject/index.android.js --bundle-output /dev/null
@int64ago

This comment has been minimized.

Copy link

@int64ago int64ago commented Jan 19, 2016

Ok, I tried again with a new project start with react-native init AwsomeProject
After npm install && npm start, I open http://localhost:8081/index.android.bundle?platform=android&dev=true in my browser and I got this:

{
message: "TransformError: /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/lib/index.js: [BABEL] /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/lib/index.js: Unknown option: /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/.babelrc.stage",
type: "TransformError",
errors: [
{ }
]
}

And then I run react-native bundle --entry-file=/home/int64ago/AwsomeProject/index.android.js --bundle-output /dev/null and I got this:

bundle: Created ReactPackager
uncaught error Error: ReferenceError: [BABEL] /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/lib/index.js: Unknown option: /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/.babelrc.stage
    at Logger.error (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/logger.js:41:11)
    at OptionManager.mergeOptions (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:262:18)
    at OptionManager.addConfig (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:221:10)
    at OptionManager.findConfigs (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:364:16)
    at OptionManager.init (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/options/option-manager.js:412:12)
    at File.initOptions (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/index.js:191:75)
    at new File (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/file/index.js:122:22)
    at Pipeline.transform (/home/int64ago/AwsomeProject/node_modules/babel-core/lib/transformation/pipeline.js:42:16)
    at transform (/home/int64ago/AwsomeProject/node_modules/react-native/packager/transformer.js:59:24)
TransformError: /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/lib/index.js: [BABEL] /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/lib/index.js: Unknown option: /home/int64ago/AwsomeProject/node_modules/react-deep-force-update/.babelrc.stage
See logs /tmp/react-packager.log
    at SocketClient._handleMessage (SocketClient.js:139:23)
    at BunserBuf.<anonymous> (SocketClient.js:53:42)
    at emitOne (events.js:77:13)
    at BunserBuf.emit (events.js:169:7)
    at BunserBuf.process (/home/int64ago/AwsomeProject/node_modules/bser/index.js:289:10)
    at /home/int64ago/AwsomeProject/node_modules/bser/index.js:244:12
    at doNTCallback0 (node.js:419:9)
    at process._tickCallback (node.js:348:13)

Here's my environment:
Ubuntu 14.04 x86_64 LTS
Node v4.2.4
NPM 3.5.3
react-native-cli: 0.1.10
react-native: 0.18.0

@int64ago

This comment has been minimized.

Copy link

@int64ago int64ago commented Jan 19, 2016

@tdzl2003

Still need to remove .babelrc manually.

It works.

@wdxgtsh

This comment has been minimized.

Copy link

@wdxgtsh wdxgtsh commented Jan 20, 2016

I have remove .babelrc manually . but no use.

@martinbigio

This comment has been minimized.

Copy link
Contributor

@martinbigio martinbigio commented Jan 21, 2016

@gaearon didn't you ship a version of react-deep-force-update without the .bablerc?

@Desmond56

This comment has been minimized.

Copy link

@Desmond56 Desmond56 commented Jan 22, 2016

@int64ago rm project_folder/node_modules/react-deep-force-update/.bablerc

@imruiyeah

This comment has been minimized.

Copy link

@imruiyeah imruiyeah commented Jan 28, 2016

for me it still didnt work after removing .bablerc

@m430

This comment has been minimized.

Copy link

@m430 m430 commented Feb 4, 2016

@martinbigio yeah, it still didn't work after removing .bablerc file. when I remove it and execute the react-native start it still have an error:

c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\file\logger.js:41
    throw new Constructor(this._buildMessage(msg));
    ^

ReferenceError: [BABEL] c:\Users\azheng\Desktop\reactNativeApp\node_modules\react-native\local-cli\bundle\bundle.js: Unknown option: base.stage
    at Logger.error (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\file\logger.js:41:11)
    at OptionManager.mergeOptions (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\file\options\option-manager.js:262:18)
    at OptionManager.init (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\file\options\option-manager.js:416:10)
    at File.initOptions (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\file\index.js:191:75)
    at new File (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\file\index.js:122:22)
    at Pipeline.transform (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\transformation\pipeline.js:42:16)
    at Object.transformFileSync (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-core\lib\api\node.js:116:10)
    at compile (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-register\lib\node.js:102:20)
    at loader (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-register\lib\node.js:130:14)
    at Object.require.extensions.(anonymous function) [as .js] (c:\Users\azheng\Desktop\reactNativeApp\node_modules\babel-register\lib\node.js:140:7)

my environment is :
react-native-cli: 0.1.10
react-native: 0.19.0
node: 4.0.0

@martinbigio

This comment has been minimized.

Copy link
Contributor

@martinbigio martinbigio commented Feb 12, 2016

@ShadowZheng does this repro after removing your node modules doing npm install? It's possible that you fetched a module that has a .babelrc. Also please do a search on the node_modules directory and make sure there's no file named .babelrc

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.