-
Notifications
You must be signed in to change notification settings - Fork 4k
Cannot build next-auth-example with target: serverless (typeorm) #2048
Description
Description 🐜
When I build the next-auth-example project with a couple of minor changes, I get:
ModuleNotFoundError: Module not found: Error: Can't resolve 'mongodb' in '/Users/andyhall/Documents/Git/sgt/next-auth-example-project/node_modules/typeorm/platform'
(sometimes mongodb is replaced by mysql or another DB provider from typeorm)
The changes are:
- Add barebones
pages/api/[...nextauth].jsfile with no providers and DATABASE_URL commented out - Set
next.config.jstomodule.exports = { target: "serverless" }; - Clean env.local from unused values
When I run yarn build (also tested npm run build) I get the typeorm error.
How to reproduce ☕️
- clone next-auth-example
yarnecho 'module.exports = { target: "serverless" }' >next.config.js- set
pages/api/[...nextauth].jsto:
import NextAuth from "next-auth";
export default NextAuth({
providers: [],
secret: "test-secret",
session: { jwt: true },
jwt: {},
pages: {},
callbacks: {},
events: {},
debug: false,
});
- run
yarn build
Screenshots / Logs 📽
Although not from next-auth-example, I built a repo with the same problem:
https://gitlab.com/supergoteam/next-auth-serverless-test/
Environment 🖥
System:
OS: macOS 11.3.1
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 2.19 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 90.0.4430.212
Firefox: 87.0
Safari: 14.1