question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Babel error causing builds to fail

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101
Binaries:
  Node: 14.16.1
  npm: 6.14.12
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.1.7-canary.10
  react: 17.0.2
  react-dom: 17.0.2

warn - Latest canary version not detected, detected: “12.1.7-canary.10”, newest: “12.1.7-canary.9”. Please try the latest canary version (npm install next@canary) to confirm the issue still exists before creating a new issue. Read more - https://nextjs.org/docs/messages/opening-an-issue

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

next run build

Describe the Bug

My deployments are failing on vercel, and when I locally run npm run build I get the following error: Error: [BABEL] /Users/mathchamp/Documents/GitHub/skillify-web/pages/_document.tsx: You gave us a visitor for the node type TSInstantiationExpression but it's not a valid type

Upon research, I think something with the latest version of babel is causing these errors.

Expected Behavior

Builds should pass with npm run build

To Reproduce

Run npm run build on the latest version of next.js

Builds that were passing yesterday are now failing.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:12
  • Comments:24 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
mihaiblaga89commented, May 23, 2022

Encountered this as well. Friday morning Babel released version 7.18.0. That comes with a new typescript feature support (https://github.com/babel/babel/issues/14322, https://github.com/babel/babel/pull/14457) that comes with a new TS 4.7 feature (https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-rc/#instantiation-expressions). Newly created projects started using that version but Next’s built-in Babel does not support that new feature, hence the error

Solution in my case was to use the yarn resolutions to pin some babel deps to latest pre-7.18 versions. Can’t give you a list because it’s quite specific to my case but check yarn.lock for babel related packages that have a 7.18.0 version and downgrade them.

7reactions
nicolo-ribaudocommented, May 29, 2022

I am releasing @babel/plugin-transform-typescript v7.18.4 that should fix this bug (it will be on npm as soon as https://github.com/babel/babel/actions/runs/2405657382 finishes, probably in 5 minutes from now).

The problem was that we were running some feature detection in the plugin to see which @babel/types features were available, but the version of @babel/types present in node_modules is different from the one that Next.js uses to run the plugin.

Read more comments on GitHub >

github_iconTop Results From Across the Web

1 - Stack Overflow
The error is fairly lengthy, but here is the first part of bundle.js error... Uncaught Error: Module build failed (from ./node_modules/babel- ...
Read more >
Options - Babel.js
json files in the project root, which can lead to unexpected errors and compilation failure. envName. Type: string. Default: process.env.BABEL_ENV || process.
Read more >
Get Help and Help Others - RedwoodJS Community
Babel error: Module build failed (from ../node_modules/babel-loader/lib/index.js) ... Hi all! I recently ran into an issue trying to upgrade from ...
Read more >
Search - appsloveworld.com
[Solved]-React build issue, ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js):-Reactjs ... Another way to solve this is ...
Read more >
[Support Guide] Frequently encountered problems during builds
Here you'll find some common build failure messages, and probable solutions to the causes. If you're looking for more general information on build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found