Babel error causing builds to fail
See original GitHub issueVerify 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:
- Created a year ago
- Reactions:12
- Comments:24 (1 by maintainers)
Top GitHub Comments
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 checkyarn.lock
for babel related packages that have a 7.18.0 version and downgrade them.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 innode_modules
is different from the one that Next.js uses to run the plugin.