TypeError Cannot read 属性 'cwd' of undefined on a TypeScript, NextJS project
TypeError Cannot read property 'cwd' of undefined on a TypeScript, NextJS project
我在网上经常看到这个错误,但在我感兴趣的情况下并没有那么多。
每当 运行 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
无论我处于开发模式还是生产模式,都会发生此错误。
我正在使用 typescript
、jest
和 babel
.
进行 nextjs
项目
显然这应该是一个 babel 兼容性问题,但在我的情况下所有包都是最新的并且应该可以协同工作:
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",
我想知道发生了什么,所有解决方案都指向包兼容性问题,none 在我的案例中似乎取得了成果...
如果您需要更多信息,请不要犹豫。
对于任何寻找答案的人来说,这实际上是一个 tsconfig
错误:
{
// some config goes here
"paths": {
"*": ["node_modules/*"],
"~/*": ["src/*"]
}
}
删除行 "*": ["node_modules/*"],
是什么把戏。
我在网上经常看到这个错误,但在我感兴趣的情况下并没有那么多。
每当 运行 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
无论我处于开发模式还是生产模式,都会发生此错误。
我正在使用 typescript
、jest
和 babel
.
nextjs
项目
显然这应该是一个 babel 兼容性问题,但在我的情况下所有包都是最新的并且应该可以协同工作:
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",
我想知道发生了什么,所有解决方案都指向包兼容性问题,none 在我的案例中似乎取得了成果... 如果您需要更多信息,请不要犹豫。
对于任何寻找答案的人来说,这实际上是一个 tsconfig
错误:
{
// some config goes here
"paths": {
"*": ["node_modules/*"],
"~/*": ["src/*"]
}
}
删除行 "*": ["node_modules/*"],
是什么把戏。