next.js: rt.toLowerCase is not a function on fresh next js init
Link to the code that reproduces this issue
https://github.com/AkipTsaqif/next-js-init-error
To Reproduce
- do
npx create-next-app@latestand follow the steps as usual - do
npm run dev - next js runs but produces error on the terminal, saying
rt.toLowerCase is not a function at \node_modules\next\dist\compiled\webpack\bundle5.js:30:274042
Current vs. Expected behavior
next js should not produces those error
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32704
Available CPU cores: 6
Binaries:
Node: 20.11.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.1 // Latest available version is detected (14.2.1).
eslint-config-next: 14.2.1
react: 18.2.0
react-dom: 18.2.0
typescript: 5.4.5
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
based on this SO question, that just been asked recently, this happens on next js 14.2
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 14
- Comments: 26 (4 by maintainers)
Hi, Console Ninja extension team member here. I can confirm the issue was caused by the patch Console Ninja makes in order to support Next.js. Apologies for the inconvenience caused by the broken patch.
As soon as the issue has been brought up to our attention, we have fixed it in less than an hour, the extension version 1.0.306 should be working with the latest version of Next.js.
@timneutkens The behaviour of patching modules in order to make the extension features work is described in the extension docs. Typically, our patches to other tools are quite small and only include our loader at the start of a tool entry file. Unfortunately, with Next.js that packs its own minified version of webpack, it is slightly harder for us. Regarding the obfuscated code of the extension - while we offer a free version of the tool for everyone, it’s a closed source project that also has a commercial Pro edition. And while every closed source software is a potential security risk as it can’t be audited, it’s worth noting that Wallaby Team (the company behind the extension and a couple more popular dev tools, such as Quokka and Wallaby) has been on the market since early 2015 for ~9.5 years, with over a million of users (both free and paid, including about 100,000 Next.js users in 1.5 years of Console Ninja only) trusting our tools to get more productive.
We have also shipped a new version of the patch that should not break Next.js if it fails to apply and will point to Console Ninja in case of any issues.
Disabling the Console Ninja VS Code Extension fixed this for me.
Seems that the Console Ninja extension changes the internals of all frameworks, i.e. it changes Next.js internals to preload code. The code of their extension is heavily mangled and can’t be audited – seems like a security risk.
Was able to confirm it adds additional code to Next.js internals and that’s why it’s breaking:
To be clear: this is editing your node_modules when you have the extension is running.
That type of changing internals is going to break between any version really, not just for Next.js but for any framework that extension supports.
I’d like to avoid having to add integrity checks for core files to Next.js as it’s quite slow. Guess we’ll have to add a big warning to Next.js when console ninja is detected 😓
Hi, I am also experiencing this issue with the
rt.toLowerCase is not a functionerror when runningyarn devin a project. Here’s the output from runningnext infoin my environment, which might help in identifying any commonalities causing this problem:Additionally, I’ve found that rolling back to Next.js version 14.1.4 resolves this issue.
@timneutkens Great idea, thanks! Apart from making sure our patches should not break target tools, we went ahead and added/released the following message to all CLI tools we integrate with:
(the URL describes the behaviour of patching modules, and how to quickly undo it).
You guys are brilliant, it really seems to be connected to Console Ninja extension.
Seems like Next.js 14.2 version doesn’t support Console Ninja VS Code Extension. Oh, Maybe Console Ninja VS Code Extension need to update fit to Next.js 14.2 version.
After disabling Console Ninja, clean
.nextandnode_modulesand reinstall dependencies to work. It seems like to happen again when installing a new dependency and Console Ninja is enabled.