我正在尝试将 Next.js 应用程序部署到 Vercel,react-swipeable 似乎有自己的类型声明,但是:
Running "npm run build"
...
> next build
...
Failed to compile.
./components/SwipeBox.tsx:5:30
Type error: Cannot find module 'react-swipeable' or its corresponding type declarations.
3 |
4 | import { NextPage } from "next";
> 5 | import { useSwipeable } from "react-swipeable";
| ^
6 |
7 | interface SwipeBoxProps {
8 | children: React.ReactNode;
...
Error: Command "npm run build" exited with 1
我需要在 tsconfig.json 中添加一些东西吗?目前看起来是这样的:
{
"compilerOptions": {
"target": "es2020",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "next.config.js"],
"exclude": ["node_modules", "next.config.js"]
}
像往常一样在本地完美构建。我错过了什么吗?
答案 0 :(得分:0)
按照@humanbean 在评论中的建议,我运行了 Redirect
并且它奏效了。
我认为具有内置类型的库意味着它不需要其他任何东西,但我错了。