Cannot find module '' or its corresponding type declarations.在Next.js项目中导入时获取。
每次导入都会发生这种情况。预览
纱线版本:3.1.0-rc.2
下一版本:11.1.2
tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"experimentalDecorators": true,
"resolveJsonModule": true,
"isolatedModules": true,
"importHelpers": true,
"jsx": "preserve",
// "baseUrl": "src"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
],
}
Run Code Online (Sandbox Code Playgroud) 我希望块内抛出的特定错误try不被处理catch(err)
例子:
const someFunc = async () => {
...
try {
...
// This error should not be handled by the catch and go straight to the middleware
throw {
status: 404,
message: "Not Found",
};
} catch (error) {
throw {
status: 500,
message: "Something went wrong",
reason: error,
};
}
};
Run Code Online (Sandbox Code Playgroud)
之后中间件处理错误。
export const errorHandler: ErrorRequestHandler = (err, req, res, next) => {
const { status = 500, message, reason } = err;
res.status(status).json({ …Run Code Online (Sandbox Code Playgroud)