facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.36k stars 24.25k forks source link

undefined is not an object (evaluating 'regeneratorRuntime.mark') #14838

Closed Amurmurmur closed 7 years ago

Amurmurmur commented 7 years ago

Is this a bug report?

Yes (write your answer here)

Have you read the Bugs section of the Contributing to React Native Guide?

(Write your answer here.)

Environment

  1. react-native -v: 0.45.1
  2. node -v: 8.1.3
  3. npm -v: 5.0.4
  4. yarn --version (if you use Yarn): 0.27.5

Then, specify:

  1. Target Platform (e.g. iOS, Android): Android
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra 10.12.5
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): Android SDK 25, Android Build Tools 25.0.2

Steps to Reproduce

(Write your steps here:)

  1. react-native init AwesomeProject
  2. react-native run-android

Expected Behavior

Should work as it did with RN v0.44.0 or RN 0.45.0 (Write what you thought would happen.)

Actual Behavior

undefined is not an object (evaluating 'regeneratorRuntime.mark')
<unknown>

loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:24
<unknown>
    index.js:2
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:24
<unknown>
    configureStore.js:19
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:24
<unknown>
    index.js:32
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:24
<unknown>
    index.android.js:10
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:119:45
_require
    require.js:110:24
global code
screen shot 2017-07-05 at 22 42 33

(Write what happened. Add screenshots!)

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

messense commented 7 years ago

+1

messense commented 7 years ago

I am getting this on 0.46

Amurmurmur commented 7 years ago

Alright seems like I've managed to fix this on RN 0.45.1 Just clean everything:

watchman watch-del-all
rm -rf $TMPDIR/react-*
rm -rf yarn.lock
rm -rf ./node_modules
yarn install

Worked for me, also unlinking and linking might help.

ernoaapa commented 7 years ago

Face same problem when creating new project with Ignite.

@Amurmurmur suggestion didn't help.

ernoaapa commented 7 years ago

Found the problem what I had (with new project generated with Ignite).

The error were pointing in my project to line import rootSaga from '../Sagas/' which contain export like this:

export default function * root () {
  yield [
    // ... snip ....
  ]
}

After changing it to this started to work:


const root = function * root () {
  yield [
    // .... snip ....
  ]
}
export default root

I'm not yet familiar with the ES6 generator functions and require support for them, but at least now I can continue. And have to say that the error were pointing to the place where the invalid export were. I hope this helps someone.

GantMan commented 7 years ago

https://github.com/infinitered/ignite/issues/1098#issuecomment-313406895

grabbou commented 7 years ago

Wasn't this fixed here? https://github.com/facebook/react-native/commit/e7c1cf5b7d2eba9468804635d0c2a0fc6725e42a

GantMan commented 7 years ago

So this won't roll out till 0.47?

grabbou commented 7 years ago

Could be, someone just need to confirm it's a fix :D Let me know and I'll do it. Planning to ship 0.46.1 soon

On Thu, 6 Jul 2017 at 17:57 Gant Laborde notifications@github.com wrote:

So this won't roll out till 0.47?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/14838#issuecomment-313439248, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWcxsfBv16-prjiBfU2Jlkk2fr-ZJVZks5sLQP4gaJpZM4OOyOI .

Amurmurmur commented 7 years ago

Tried to fix with the suggested Saga solution, its surely something to do with saga because when I comment out saga implementation in my configureStore, the error is gone however trying suggested solution doesnt work for me. :/

Amurmurmur commented 7 years ago

@grabbou @GantMan @ernoaapa Alright guys, figured out the problem downgraded babel-preset-react-native form 2.1.0 to 2.0.0 all works fine on Android/iOS Though once upgraded to 0.46 the error comes back. As for RN 0.47-rc.0, most packages I have linked, wont work due to some changes to the api of the react-native I guess because they will throw errors such as:

:react-native-blur:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/Users/amurmurmur/exampleapp/node_modules/react-native-blur/android/src/main/java/com/cmcewen/blurview/BlurViewPackage.java:23: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: /Users/amurmurmur/exampleapp/node_modules/react-native-blur/android/src/main/java/com/cmcewen/blurview/BlurringView.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:react-native-blur:compileReleaseJavaWithJavac FAILED
kcalmes commented 7 years ago

@Amurmurmur I am still seeing the issue on 0.45.1 even after downgrading babel. I wonder how much node and npm versions might be affecting which fixes work and which ones don't. node: v8.1.0 npm: 5.1.0 OS: macOS Sierra 10.12.5

Amurmurmur commented 7 years ago

@kcalmes Make sure you reset react-native packager after you've downgraded babel with:

npm start -- --reset-cache
kcalmes commented 7 years ago

That did the trick, I previously deleted the node_modules dir, but I didn't realize I missed the other cache. Thanks for your help @Amurmurmur!

brentvatne commented 7 years ago

@facebook-github-bot close

facebook-github-bot commented 7 years ago

@brentvatne tells me to close this issue. If you think it should still be opened let us know why.

vongohren commented 7 years ago

Still experiencing this with 0.46.1 and babelrc on both 2.0.0 and 2.1.0. Tried all the things done here but it doesnt fix it. Why was this closed @brentvatne @grabbou

Amurmurmur commented 7 years ago

@vongohren Double make sure you reset the packager, Im using react-native 0.46.1 and babel at 2.0.0 all good on both platforms Debug/Release builds. Please make sure you run

watchman watch-del-all
rm -rf ./node_modules
rm -rf $TMPDIR/react-*
npm i babel-preset-react-native@2.0.0 -D -S
npm install
npm start -- --reset-cache
react-native run-ios

Also make sure you reset your android/ios emulator/simulator, delete both android/ios build folders.

vongohren commented 7 years ago

Loool, this is what I have done all the way, but I did not reset the emulator and delete the build folder. Seemed to help, thanks man. But can anyone answere why this happens? @grabbou @brentvatne

Edit: This did solve my android problem, but produces different iOS problems. What are the different clearing options of ios? Clear derivated folders? Pod install again. What else @Amurmurmur ? Im running Cocoapods and swift on iOS

yabeow commented 7 years ago

Downgrade babel-preset-react-native to 2.0.0 work for me too. But why 2.1.0 don't work?

matt-oakes commented 7 years ago

Downgrading worked for me, but I'd also like to know what the issue actually is and what a real fix is.

vongohren commented 7 years ago

Running a completly new project, that is not dependent on cocoapods or swift, works out of the box. I did not try to add all my dependencies but that could be a test case.

Amurmurmur commented 7 years ago

@vongohren Indeed the fresh project will work for you however once you start using babel features such as export/import you will face the problem with babel-preset-react-native 2.1.0 This is a relevant issue #14933

poupryc commented 7 years ago

Same issue here, from react-native version 0.45.1 on Linux subsystem for Windows, downgrading babel-preset and @Amurmurmur's method doesn't work

Amurmurmur commented 7 years ago

@HelloEdit But it works, can you share an example project where the problem occurs for you ? It works fine on my side no matter RN 0.45.1 or 0.46.1 all still.

kaxline commented 7 years ago

For me, using yarn instead of npm was the only thing that worked.

watchman watch-del-all
rm -rf ./node_modules
rm -rf $TMPDIR/react-*
npm cache clean
yarn cache clean
yarn install
yarn start -- --reset-cache
react-native run-ios

I also downgraded babel-preset-react-native to 2.0.0, so I'm not sure if it was the combination or just switching to yarn.

spiskommg commented 7 years ago

yes yes yes! @kaxline i agree with your yarn theory. relying on that as well as downgrade babel-preset-react-native@2.0.0, react@045.1, and moving /node_modules/react-native/packager/react-native-xcode.sh to =>
/node_modules/react-native/scripts/react-native-xcode.sh

finally! i've been trying everything for the past few hours.

poupryc commented 7 years ago

I upgrade my project to RN 0.46.1, and it's work !

@Amurmurmur Please, in programming, never say "it works on my PC though" 😄

anhngd commented 7 years ago

@kaxline Thank you. It worked for me!

arufian commented 7 years ago

@HelloEdit updated to 0.46.1 didn't work for me.

Is there any clear solution ?, I don't want to downgrade babel-preset-react-native every time I set redux-saga for my react-native app.

poupryc commented 7 years ago

↪️ @arufian Hum...Just change the version did not work for me, I had to regenerate a new project (I used ignite) with RN 0.46.2

dioxide commented 7 years ago

The problem still here in RN 0.46.4 , unless downgrade babel-preset-react-native to 2.0.0

poupryc commented 7 years ago

↪️@dioxyde Have you tried 0.46.2 ? It's work like a charm for me 👍

Amurmurmur commented 7 years ago

@dioxide Running RN 0.46.4 with babel-preset-react-native 2.0.0 just fine.

Try reseting the packager with npm start -- --reset-cache

tugorez commented 7 years ago

Another workaround pointed by Markus in https://github.com/facebook/react-native/issues/14933 which doesnt require downgrade the babel preset is to use variables so

instead of

function* foo() {}

do

const foo = function* foo() {}
sayhei commented 7 years ago

oh no,this solutions all not work for me

Amurmurmur commented 7 years ago

@sayhei imposibru Most likely you have to: clean yarn/npm cache install babel with yarn add babel-preset-react-native@2.0.0 run React-native packager with npm start -- --reset cache, and rebuild the debug/release builds

Noitidart commented 7 years ago

In RN 0.47.1 even just doing this:

function* upAsyncWorker(action: UpAsyncAction) {
/// ...
}

Without an export is causing this error. I fixed it by doing the const trick above. So this works now:

const upAsyncWorker = function* upAsyncWorker(action: UpAsyncAction) {
/// ...
}
Amurmurmur commented 7 years ago

The only question I have is that, the const way of exporting sagas, going to be the standard now? Or next babel-present release will fix that ?

Dimon70007 commented 7 years ago

Another workaround pointed by Markus in #14933 which doesnt require downgrade the babel preset is to use variables so

instead of

function* foo() {}

do

const foo = function* foo() {}

It is work for me too, but only with latest versions of react-native and babel-preset-react-native. I am happy)))

fernandopasik commented 7 years ago

I tried babel-preset-react-native v3.0.0 and still see the same issue

poupryc commented 7 years ago

Hello @brentvatne, this issue is apparently always present... Consider its re-opening please : )

gibo commented 7 years ago

is still an issue in react-native .47 tried downgrading to babel-preset-react-native v2.0.0

shenjunru commented 7 years ago

This issue caused by commits:

This code will be inserted by babel. And the order of variables causes the undefined issue.

var _marked = regeneratorRuntime.mark(...);
var regeneratorRuntime = require("regenerator-runtime"); // inserted by the new transformer

The solution is use babel-preset-react-native <= 2.0.0

poupryc commented 7 years ago

Yep it's good solution while waiting for a patch of presets Nobody knows if it will happen soon?

Noitidart commented 7 years ago

Hello @brentvatne, this issue is apparently always present... Consider its re-opening please : )

Oh wow I'm super surprised to see this closed. Closing this says "no we don't want to support the standard established syntax". Is there a valid perf reason like the empty object assign?

poupryc commented 7 years ago

Hello @Noitidart, I'm definitely a bit naive but I think it's just a bug, not a stuff like "change everything and say nothing to anyone". If a member of the react team wanted to give us an answer, we would all be happy I think...

poupryc commented 7 years ago

PS: I absolutely do not know how the Facebook bot works for Github, we can not ask him to reopen the issue?

shenjunru commented 7 years ago

Hi @mjesun, could you follow this issue, either improve the transformer or remove it. Thanks.

brentvatne commented 7 years ago

hello! this seems to be a problem for everyone using redux-sagas, I don't use it and I don't really touch this part of the code so if someone wants to fix it, that would be great. please include a unit test in the fix so it doesn't regress in the future.