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
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@corbt
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

ide commented Jan 7, 2016

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

@corbt
Copy link
Contributor Author

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
Copy link
Contributor

satya164 commented Jan 8, 2016

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

@floatinghotpot
Copy link

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.

@etodanik
Copy link

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

@mkonicek
Copy link
Contributor

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

@mkonicek
Copy link
Contributor

Thanks so much for using the rc everyone!

@tdzl2003
Copy link
Contributor

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

@martinbigio
Copy link
Contributor

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

@chshouyu
Copy link

thanks all, waiting for release.

@jinzhaoyu
Copy link

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
Copy link
Contributor

@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
Copy link

+1, waiting for fixing, thx :-)

@corbt
Copy link
Contributor Author

corbt commented Jan 19, 2016

0.18 is out now and this problem has been fixed!

@corbt corbt closed this as completed Jan 19, 2016
@int64ago
Copy link

@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
Copy link

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
Copy link
Contributor

Still need to remove .babelrc manually.

@corbt
Copy link
Contributor Author

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
Copy link

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

@corbt
Copy link
Contributor Author

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
Copy link

Almost the same as:

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

@corbt
Copy link
Contributor Author

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
Copy link

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
Copy link

@tdzl2003

Still need to remove .babelrc manually.

It works.

@wdxgtsh
Copy link

wdxgtsh commented Jan 20, 2016

I have remove .babelrc manually . but no use.

@martinbigio
Copy link
Contributor

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

@Desmond56
Copy link

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

@imruiyeah
Copy link

for me it still didnt work after removing .bablerc

@m430
Copy link

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
Copy link
Contributor

@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

@imruiyeah
Copy link

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests