Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using external babel configuration breaks node/react app - internal server error

Does anyone have any clue why a babel config file would be loaded on npm run dev and why it would start flagging perfectly fine parts of my code?

I have a feeling it has something to do with Next.js. My package.json (that Im testing with) for reference:

},
"devDependencies": {
  "@babel/preset-env": "^7.4.5",
  "@babel/preset-react": "^7.0.0",
  "@svgr/cli": "^4.2.0",
  "babel-jest": "^24.8.0",
  "babel-preset-stage-2": "^6.24.1",
  "jest": "^24.8.0",
  "nodemon": "^1.19.1"
}

My goal is to have an app that runs both npm run dev and npm test and not one or the other. At the moment, if I remove all my babel config files (needed to run jest), my web app will boot up perfectly fine. And vice versa. Honestly I don't think I need or want any babel config files to be active when I start running the server, but I need them to run jest.

So... either there is a way to disable babel from certain package.json scripts or otherwise get jest tests to work without breaking the core functionality of the app?

edit-i fixed it

like image 718
notacorn Avatar asked Oct 26 '25 02:10

notacorn


1 Answers

//.babelrc

{
  "presets": [
    [
      "next/babel"
    ]
  ]
}
like image 143
notacorn Avatar answered Oct 28 '25 16:10

notacorn