Adding _app.js to 'with-firebase-hosting' causes "Cannot find module '@babel/runtime/regenerator'"
See original GitHub issueDescribe the bug I have cloned the with-firebase-hosting example, seen here: https://github.com/zeit/next.js/tree/canary/examples/with-firebase-hosting
The only change I have made are as follows:
- Configured
.firebaserc
to my project - Change
src/functions/.babelrc
to the following (fixes another issue)
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "6.11.5"
}
}
]
]
}
- Have added an
_app.js
insrc/pages/_app.js
that looks as follows:
import App, { Container } from 'next/app';
import React from 'react';
class MyApp extends App {
static async getInitialProps({ Component, router, ctx }) {
let pageProps = {};
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx);
}
return { pageProps };
}
render() {
const { Component, pageProps } = this.props;
return (
<Container>
<Component {...pageProps} />
</Container>
);
}
}
export default MyApp;
When I run yarn deploy
, although the deploy is successful, I receive the following error in my Firebase console
{ Error: Cannot find module '@babel/runtime/regenerator'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/next/dist/bundles/pages/_app.js:193:18)
at __webpack_require__ (/user_code/next/dist/bundles/pages/_app.js:23:31)
at Object.<anonymous> (/user_code/next/dist/bundles/pages/_app.js:94:85)
at __webpack_require__ (/user_code/next/dist/bundles/pages/_app.js:23:31)
at Object.module.exports.Object.defineProperty.value (/user_code/next/dist/bundles/pages/_app.js:85:18)
at __webpack_require__ (/user_code/next/dist/bundles/pages/_app.js:23:31) code: 'MODULE_NOT_FOUND' }
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
yarn deploy
after making my changes, and attempt to hit the deployed url
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Error: Cannot find module '@babel/runtime/regenerator'
Hello guys I am getting this error on my node application when I build it for production and deploy to my server. Server...
Read more >build:css error regarding missing interopRequireWildcard
When I run yarn build:css I get the error. Cannot find module '@babel/runtime/helpers/interopRequireWildcard'. I can fix it by adding the ...
Read more >@babel/runtime | Yarn - Package Manager
Intro. Babel is a tool that helps you write code in the latest version of JavaScript. When your supported environments don't support certain...
Read more >Cannot find module 'babel-runtime/regenerator' Import locally ...
Coding example for the question Cannot find module 'babel-runtime/regenerator' Import locally vs Import from NPM-babel.js.
Read more >Cannot find module '@babel/runtime/helpers/defineProperty ...
Error: Cannot find module '@babel/runtime/helpers/defineProperty' from '/opt/gitter/gitter-webapp-staging/output/assets/js' File ...
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
@Ghostavio - I am currently using babel now and it’s working (with node 8 on firebase functions functions / client side as well).
This is all my babel stuff - IDK how I got here but it works lol
Webpack
Package.json dev dependencies
Babel.rc
This seems to be unrelated to the
.babelrc
file and more the Next.js 6 upgrade to@babel v7
.I created a minimal reproduction without the use of babel https://github.com/jthegedus/nextjs-with-firebase-hosting-issue-reproduction
The Cloud Function runtime fails when the compiled
_app.js
file requires@babel/runtime/regenerator
. Despite this being included in thenext.js
package.json
. However, by adding@babel/runtime
explicitly to thepackage.json
it does…I’m not sure what the cause is here. Whether it be how Firebase/Cloud Functions installs and stores
node_modules
, or the pkg manager it installs the dependencies with or how it is exposed as a dependency of next.js.I ran into a bunch of different errors when trying to compile Next.js 6 with the existing example. I believe the cause is conflicting/overriding
@babel
deps. Removing them frompackage.json
and relying on the ones installed by Next.js seems to work (except in the runtime case of@babel/runtime
).I will update the
with-firebase-hosting
example accordingly.