JavaScript does not get loaded on the custom _error.js page
See original GitHub issueNone of my JavaScript gets loaded on the custom _error page in a production bundle, works fine in development though.
There’s also things on the _error page that are reused elsewhere in the application like a common header that has some JavaScript for letting a user log in/sign out.
In the console I can see some errors saying the scripts can’t be found. Is this normal behaviour that you simply can’t run any JavaScript on the _error page? Is there any way to hack around this?
asdf:1 GET https://<BASE_URL>/_next/56777ac5-5382-4caf-9a49-e437db6e03a1/page/asdf.js net::ERR_ABORTED
- I have searched the issues of this repository and believe that this is not a duplicate.
Steps to Reproduce (for bugs)
- Create a custom _error.js page in the pages folder that’s part of next’s api
- Go to a route that doesn’t exist
Context
I was asked to implement a newsletter subscription form on the custom error page in order to give the user the ability to be notified as soon as a certain page exists because we have links that don’t lead anywhere yet for a second stage of the project.
Your Environment
Tech | Version |
---|---|
next | 4.2.3 |
node | 9.5.0 |
OS | Mac OS X |
Chrome | 65.0.3325.181 |
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
JavaScript does not get loaded on the custom _error.js page
None of my JavaScript gets loaded on the custom _error page in a production bundle, works fine in development though.
Read more >How do I create a custom Error in JavaScript? - Stack Overflow
This confirmes the "problem" I ran into was the stack property of the error was the line number where new Error() was created,...
Read more >Custom errors, extending Error - The Modern JavaScript Tutorial
JavaScript allows to use throw with any argument, so technically our custom error classes don't need to inherit from Error .
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >Creating Custom Errors in JavaScript - YouTube
Did you know that you can create your own custom Error objects in JavaScript ? This can be accomplished with both the older...
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
The error is actually pretty clear,
this must be an object. Seems like it’s an open pull request here: https://github.com/entwicklerstube/babel-plugin-root-import/pull/93
Also
["transform-define", "./env-config.js"]
must be an object too, you can do this using.babelrc.js
: https://github.com/zeit/next.js/issues/4239#issuecomment-385775369Going to close this as it works fine on latest.