Next.js Discord

Discord Forum

Identifier 'n' has already been declared

Unanswered
Huntaway posted this in #help-forum
Open in Discord
HuntawayOP
Hi there, I'm trying to debug an error I'm receiving after updating to Next JS 16. I did what the documentation suggested and switched to turbopack, and after adding a rule for SVGs, I was able to get everything working locally. I was psyched because the previous upgrade attempt, we were trying to keep webpack, but that kept introducing problems. I go to build and deploy my app, only to be met with what's in the thumbnail.

So far, I've tried downgrading from 16.1.1 to 16.1.0, I've tried adding the flag that produces production source maps to try and find the error, and I've tried scouring my code to see if I manually use 'n' anywhere in a big enough scope that would trip things up. Next JS 16 is the only package I've updated with this change, and everything is still working if I run it on Next JS 15.

My main question is: Can I un-minify the static chunks that this error is coming from? I want to see if it's a specific page that's causing the problem, like maybe a page is importing something twice on accident. If anyone else has seen this issue with Next JS 16 and has solved it, I would love to hear your perspective.

11 Replies

HuntawayOP
I tried out the bundle analyzer and this seems to be the problem chunk. Its location is the same place as the error and I don't see any other package that's part of this chunk but i'm going to keep looking. I updated this package to the latest version just in case but it hasn't worked yet and I'm still getting this error.
HuntawayOP
has no one else experienced this? idk where I could possibly be double-importing this module but it seems to be the case for some reason
Saint Hubert Jura Hound
Have u tried to replicate the error in a fresh project? Usually the fastest way to see where errors like this are coming from
HuntawayOP
Yeah I tried in a coding sandbox and I got the same behavior but without the console error for some reason. I sent in a ticket to Microsoft and someone's working on it on their end as well. I'm currently trying to see if it's a compiler/transpiler issue and testing out babel, transpiling packages, etc to see if that changes anything
Saint Hubert Jura Hound
Which behavior do u mean? U only mentioned an error before
HuntawayOP
Ah sorry! I meant to bring that up more. Due to this error I'm experiencing, my Azure maps just don't load at all. Complete white screen where the map should be. I was able to replicate the empty map in a sandbox but it didn't have the error I was seeing, which I found to be quite odd
But good news! I was able to find a workaround
Instead of using turbopack, I enabled Babel and switched to webpack. I also included azure-maps-control and azure-drawing-tools in the packages to be transpiled. Using the basic babel config worked fine for me I think, but combining it with webpack removed the error for me and my maps are displaying again
I'll leave this up in case anyone else has a similar problem but I'm glad I was able to figure it out and provide a solution. And if Microsoft support provides an update for azure maps, I'll include it here too
Saint Hubert Jura Hound
No worries flad u got it fixed finally. Might be worth creating an issue if u didnt already
HuntawayOP
ohh probably! I'll try and do that