javascriptreactjsnext.jsbabeljsnpm-package

Build failed because of webpack errors


I am getting below error from next js app suddenly. Any solution to fix that problem?

./pages/_app.tsx
Error: [BABEL] C:\Projects\skribeNew\app-web\pages\_app.tsx: You gave us a visitor for the node type TSSatisfiesExpression but it's not a valid type
    at verify (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:397612)
    at Function.explode (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:396515)
    at C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1:49254
    at Generator.next (<anonymous>)
    at Function.<anonymous> (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1:79767)
    at Generator.next (<anonymous>)
    at evaluateSync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:717268)
    at Function.sync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:715284)
    at sync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1:80263)
    at sync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:716601)

I changed the babel types version to previous one, But it did not work.


Solution

  • It was because of an incompatible version issue for the npm package "@babel/plugin-transform-typescript". I fixed to the correct previous version in package.json file. Now it's working fine. Below is the code -

    "devDependencies": {    
       "@babel/plugin-transform-typescript": "7.19.3",
    }
    "resolutions": {   
       "@babel/plugin-transform-typescript": "7.19.3"
    }