Next.js: Const must be initialized, IE11

Created on 23 Sep 2019  ·  11Comments  ·  Source: vercel/next.js

Bug report

Describe the bug

IE11 errors on the file https://github.com/zeit/next.js/blob/2ba352da39ee00b6595aecdc9ffb2f103e803a85/packages/next/next-server/server/utils.ts#L6 returning a Const must be initialized.

Seems as though this issue has come up in the past - https://github.com/zeit/next.js/issues/4334

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a fresh Next.js instance
  2. Create a page in pages directory
  3. Open IE11
  4. See error in console

Expected behavior

Return no error.

Screenshots

image
image

System information

  • OS: macOS 10.14.6 (running BrowserStack)
  • Browser: IE11
  • Version of Next.js: 9.0.6
please add a complete reproduction p1

Most helpful comment

Interesting... our tests passed for IE 11 for this release:
image

We'll dig into this and make sure it causes our tests to fail, thanks for reporting!

All 11 comments

Interesting... our tests passed for IE 11 for this release:
image

We'll dig into this and make sure it causes our tests to fail, thanks for reporting!

Hi, I'm not able to reproduce this with a minimal Next.js app. Can you provide a link to a repo encountering this issue?

@ijjk interesting. I'll try to provide a repo that can reproduce.

@jonkwheeler do you happen to have a .babelrc somewhere in your file tree above your project? Maybe your home directory?

@Timer it does not actually...


_Some time goes by testing........_


My main site does not have a .babelrc, but that got me thinking, my Design System package does. Next.js is peer dependency there (if that matters). All I did was create a new Next.js instance, install the package, and use one component from it. The moment I used the package, it broke with the same error. Not before. So Next.js is completely in the clear here. Except, why in the hell is the error saying it's a problem with Next.js, and not the package? That bothers me.

https://stackoverflow.com/questions/37799669/const-must-be-initialized-error-in-microsoft-edge-in-for-of-loop

Hello Please Check it.

I Think We Can Fix it ,just with changing const with let.

Apparently this is a very misleading error. The error says it's one thing, but it's def not. Next works in IE11 100%. Maybe it'd be better to focus on why the error is reporting wrongly 🤷‍♀️

Following up here. I have successfully traced this back to being Next.js _when included as a peer dependency on another dependency_. Meaning... if you have a Next.js app, and you install my-package on it, and my-package has Next.js installed (in my case as a peer dependency), then this error will bite (at least on my setup).

I wanted to use Next as a dependency so I have access to Next/Link, Next/Head, Next/Document, and for typing. Have any direction as to how I can include it as a dependency on my-package but not cause such an error?

Is there any workaround for this issue ?

@poying only think I did was stop using Next as a dependency in another package. Even as a Peer dependency, this failed.

Related to #706 (and you had 2 versions of next bundled).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wagerfield picture wagerfield  ·  3Comments

havefive picture havefive  ·  3Comments

formula349 picture formula349  ·  3Comments

knipferrc picture knipferrc  ·  3Comments

renatorib picture renatorib  ·  3Comments