reactjs - 找不到模块:无法解析“/vercel/path0/components”中的“next-auth/react”
问题描述
我正在尝试通过 vercel 部署我的 next.js 应用程序。使用命令“npm run dev”在本地运行良好。但是当我尝试使用 Github 远程存储库通过 vercel 部署它时,它会抛出如下错误:
warn - No ESLint configuration detected. Run next lint to begin setup
info - Creating an optimized production build...
warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
Failed to compile.
./components/Feed.js
Module not found: Can't resolve 'next-auth/react' in '/vercel/path0/components'
Import trace for requested module:
./pages/index.js
./components/Header.js
Module not found: Can't resolve 'next-auth/react' in '/vercel/path0/components'
Import trace for requested module:
./pages/index.js
./components/MiniProfile.js
Module not found: Can't resolve 'next-auth/react' in '/vercel/path0/components'
Import trace for requested module:
./components/Feed.js
./pages/index.js
./components/Modal.js
Module not found: Can't resolve 'next-auth/react' in '/vercel/path0/components'
Import trace for requested module:
./pages/index.js
./components/Post.js
Module not found: Can't resolve 'next-auth/react' in '/vercel/path0/components'
Import trace for requested module:
./components/Posts.js
./components/Feed.js
./pages/index.js
> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1
这是我的 package.json
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@headlessui/react": "^1.4.2",
"@heroicons/react": "^1.0.5",
"@tailwindcss/forms": "^0.3.4",
"axios": "^0.24.0",
"faker": "^5.5.3",
"firebase": "^9.3.0",
"moment": "^2.29.1",
"next": "latest",
"next-auth": "^4.0.0-beta.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-moment": "^1.1.1",
"recoil": "^0.5.2",
"tailwind-scrollbar-hide": "^1.1.5"
},
"devDependencies": {
"autoprefixer": "^10.2.6",
"postcss": "^8.3.5",
"tailwind-scrollbar": "^1.3.1",
"tailwindcss": "^2.2.4"
}
}
任何想法为什么在 Vercel 上部署时会引发编译错误?