next.js: Serverless API routes not working

Working in development, but when deploying to now every api route has the following error in the logs.

TypeError: require is not a function
    at Object.+nUH (/var/task/page.js:12162:14)
    at __webpack_require__ (/var/task/page.js:23:31)
    at Object.ubcj (/var/task/page.js:432129:20)
    at __webpack_require__ (/var/task/page.js:23:31)
    at Object.ug46 (/var/task/page.js:432406:20)
    at __webpack_require__ (/var/task/page.js:23:31)
    at Object.1XFb (/var/task/page.js:27759:15)
    at __webpack_require__ (/var/task/page.js:23:31)
    at Object.qEY2 (/var/task/page.js:410688:11)
    at __webpack_require__ (/var/task/page.js:23:31)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Thanks so much @Timer! Everything in Next v9 is INCREDIBLE!

Thank you for the awesome detective work @ecwyne!

Found this https://github.com/fauna/faunadb-js/issues/133

Which led me to https://github.com/felixge/node-formidable/issues/337

And the suggested solution of https://github.com/felixge/node-formidable/issues/337#issuecomment-153408479

plugins: [
     new webpack.DefinePlugin({ "global.GENTLY": false })
],

I am using "next": "^9.0.1-canary.1"

next dev 👍 next build && next start 👎 @now/next (running in zeit/now) 👎