question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: App is not defined

See original GitHub issue

When starting up my dev server with the latest version of next-translate, I ran into this webpack issue:

ReferenceError: App is not defined at eval (webpack-internal:///./pages/_app.js:185:1)

After some debugging, It seems to have something to do with the App.propTypes in the _app.js file, when exporting the App while defining it:

import PropTypes from "prop-types";

export default function App({ Component, pageProps }) {
 return <Component {...pageProps} />
}

App.propTypes = {
  Component: PropTypes.any,
  pageProps: PropTypes.any,
}

I managed to narrow it down to a minimal reproducible example. You can find my repository here.

It’s based on the simple example of the next-translate example directory. Hopefully the comments in the _app.js and next.config.js files are clear enough to reproduce the issue!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
giladayacommented, Aug 3, 2021

Until a fix is released and in case it helps anyone -

I had a similar issue and found out this can be worked-around by not directly exporting the App component from _app file.

In my case, changing from this:

//...

export default function MyApp({ Component, pageProps }: AppProps) {
  return (
    <ApolloProvider client={client}>
      <Component {...pageProps} />
    </ApolloProvider>
  );
}

to this:

//...

function MyApp({ Component, pageProps }: AppProps) {
  return (
    <ApolloProvider client={client}>
      <Component {...pageProps} />
    </ApolloProvider>
  );
}

export default MyApp

Solved the error.

1reaction
aralrocacommented, Sep 20, 2022

@jellebouwman @giladaya @justirva09 @j-schumann The idea of 2.0 version is to change the regular expressions in a better way. Currently, there are 2 proposals: with Babel parser and with TypeScript compiler.

We need feedback from the people to decide which one corrects more errors and does not generate new ones.

This bug should be fixed with the new version Can you test these two prereleases and give feedback?

With Babel: 2.0.0-experimental.1

With TypeScript compiler: 2.0.0-experimental.2

You can use this discussion to write your feedback:

https://github.com/aralroca/next-translate/discussions/881

Thank you so much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: app is not defined: node.js - Stack Overflow
Error message is pretty clear. app variable is not defined, so obviously you can not use it. Check example from the link in...
Read more >
ReferenceError: App is not defined · Issue #488 - GitHub
When starting up my dev server with the latest version of next-translate, I ran into this webpack issue: ReferenceError: App is not defined...
Read more >
ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
ReferenceError : "x" is not defined. The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >
uncaught reference error: App is not defined - Treehouse
render( <App />, document. getElementById("root") ); this shows an uncaught reference error saying App wasn't defined. However, when I copied ...
Read more >
Referenceerror message is not defined Node js
Reference Error [variable] is not defined. In some cases, this can be simply referring to a variable that isn't defined (perhaps the most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found