TypeError Cannot read property 'cwd' of undefined on a TypeScript, NextJS project

Viewed 897

I have seen this error a lot on the web but not so much in the case that interests me.

I am getting the following error whenever I run yarn dev :

next-dev.js?53bc:89 Error was not caught TypeError: Cannot read property 'cwd' of undefined
    at Module.eval (parsers.js?f09d:27)
    at eval (parsers.js:252)
    at Module../node_modules/@sentry/node/esm/parsers.js (_app.js?ts=1619702971940:3455)
    at __webpack_require__ (webpack.js?ts=1619702971940:873)
    at fn (webpack.js?ts=1619702971940:151)
    at eval (backend.js?5e1f:1)
    at Module../node_modules/@sentry/node/esm/backend.js (_app.js?ts=1619702971940:3299)
    at __webpack_require__ (webpack.js?ts=1619702971940:873)
    at fn (webpack.js?ts=1619702971940:151)
    at eval (index.js?54d7:1)
    at Module../node_modules/@sentry/node/esm/index.js (_app.js?ts=1619702971940:3335)
    at __webpack_require__ (webpack.js?ts=1619702971940:873)
    at fn (webpack.js?ts=1619702971940:151)
    at Module.eval (_app.tsx:16)
    at eval (_app.tsx?8548:93)
    at Module../src/pages/_app.tsx (_app.js?ts=1619702971940:11957)
    at __webpack_require__ (webpack.js?ts=1619702971940:873)
    at fn (webpack.js?ts=1619702971940:151)
    at eval (next-client-pages-loader.js?7ae7:5)
    at eval (route-loader.ts?8a46:294)
    enter code here

This error happens whether I'm in development mode or production. I am on a nextjs project using typescript, jest and babel.

Apparently it is supposed to be a babel compatibility issue, but in my case all the package are up to date and should work together:

package.json

"@types/testing-library__jest-dom": "5.9.5",
"@babel/core": "7.13.1",
"@types/jest": "26.0.23",
"babel-jest": "26.6.3",
"jest": "26.6.3",
"ts-jest": "26.5.5",

I am wondering what is going on, all the solutions pointed at package compatibility issues, none of which seem to bear fruits in my case... If you need more info, don't hesitate.

1 Answers

For anybody searchhing for the answer, it was actually a tsconfig error:

{
    // some config goes here
    "paths": {
      "*": ["node_modules/*"],
      "~/*": ["src/*"]
    }
}

removing the line "*": ["node_modules/*"],is what did the trick.

Related