Crash on AWS Amplify build: "Building SSR... can't find mongodb"
See original GitHub issueDescription 🐜
Hi! When building my project on AWS Amplify, the build crashes with complaints for missing mongodb
in typeorm
. Build logs are below. This doesn’t occur locally.
Not sure why this is happening as I don’t use any database in my Next Auth configuration. I saw issue #2358 but I’m not doing any transpilation in my project.
Please let me know if there is more context I could give!
Is this a bug in your own project?
No
How to reproduce ☕️
This is my [...nextauth].js
file. I also want to note that my project uses TypeScript for mostly everything else but I left NextAuth in JavaScript for simplicity.
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
const GOOGLE_NEEDED_SCOPES = [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email ',
'https://www.googleapis.com/auth/business.manage',
'https://www.googleapis.com/auth/admin.directory.user',
].join(' ')
export default NextAuth({
providers: [
Providers.Google({
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
scope: GOOGLE_NEEDED_SCOPES,
authorizationUrl:
'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code',
accessTokenUrl: 'https://oauth2.googleapis.com/token',
}),
],
callbacks: {
async jwt(token, user, account, profile, isNewUser) {
if (account?.accessToken) {
token.accessToken = account.accessToken
token.refreshToken = account.refreshToken
}
return token
},
async session(session, token) {
session.accessToken = token.accessToken
session.refreshToken = token.refreshToken
return session
},
},
secret: process.env.NEXT_AUTH_SECRET,
})
and here is my next.config.js
:
module.exports = {
reactStrictMode: true,
}
Screenshots / Logs 📽
2021-07-28T10:59:17.174Z [INFO]: Starting SSR Build...
2021-07-28T11:00:22.834Z [ERROR]: Error: Command failed with exit code 1: node_modules/.bin/next build
Failed to compile.
ModuleNotFoundError: Module not found: Error: Can't resolve 'mongodb' in '/codebuild/.../node_modules/typeorm/platform'
> Build error occurred
Error: > Build failed because of webpack errors
Environment 🖥
System: OS: macOS 11.2.1 CPU: (8) x64 Apple M1 Memory: 21.89 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node Yarn: 1.22.10 - /opt/homebrew/bin/yarn npm: 7.6.3 - ~/.nvm/versions/node/v14.15.4/bin/npm Watchman: 2021.06.07.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 92.0.4515.107 Safari: 14.0.3 npmPackages: next: 11.0.1 => 11.0.1 next-auth: ^3.27.3 => 3.27.3 react: 17.0.2 => 17.0.2
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (7 by maintainers)
I got this error, I fix setting
webpack5: false
on next.config.js.So then we can close this?