简体   繁体   中英

Getting `Cannot find module '.next\server\pages-manifest.json'` error when trying to add `babel.config.js` in nextjs app

I was trying to set up testing for my existing next app. We installed jest , babel-jest @babel/preset-env , @babel/preset-react and, react-test-renderer and then created babel.config.js . When I remove this file, everything works fine.

As soon as I add the babel.config.js file, I get this error

Cannot find module '.next\server\pages-manifest.json'

The content of babel.config.js file is

module.exports = {
  presets: ['@babel/preset-env', '@babel/preset-react'],
};

When using next.js you need to use next/babel preset as shown below

module.exports = {
    presets: ['@next/babel'],
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM