-
Notifications
You must be signed in to change notification settings - Fork 67
"The 'path' argument must be of type string. Received undefined" when using next-auth #168
Description
Describe the bug
I initially raised a bug on the next-auth
repo here: nextauthjs/next-auth#1311
I am using next-on-netlify
with next-auth
. I am able to enter my email address at /api/auth/signin
, but the following page (/api/auth/signin/email
) shows the following runtime error:
{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string. Received undefined","trace":["Runtime.UnhandledPromiseRejection: TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string. Received undefined"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:314:20)"," at processPromiseRejections (internal/process/promises.js:209:33)"," at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
The full logs on Netlify show the following:
11:22:40 PM: 2021-02-13T23:22:40.108Z b4c355c3-801b-4f2e-b1a4-9c1fc1f1ef88 INFO [request] /api/auth/signin
11:22:40 PM: Duration: 25.63 ms Memory Usage: 133 MB Init Duration: 632.42 ms
11:22:45 PM: 2021-02-13T23:22:45.318Z 754432c8-0294-4ed2-b94e-09ee1c1657bb INFO [request] /api/auth/signin/email
11:22:45 PM: 2021-02-13T23:22:45.825Z 754432c8-0294-4ed2-b94e-09ee1c1657bb WARN Warning: no saslprep library specified. Passwords will not be sanitized
11:22:46 PM: 2021-02-13T23:22:46.115Z 754432c8-0294-4ed2-b94e-09ee1c1657bb ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string. Received undefined","reason":{"errorType":"TypeError","errorMessage":"The \"path\" argument must be of type string. Received undefined","code":"ERR_INVALID_ARG_TYPE","stack":["TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string. Received undefined"," at validateString (internal/validators.js:120:11)"," at Object.dirname (path.js:1128:5)"," at find_package_json (/var/task/src/nextPage.js:132745:23)"," at find_package_json_with_name (/var/task/src/nextPage.js:132762:20)"," at require_optional (/var/task/src/nextPage.js:132797:13)"," at Object.<anonymous> (/var/task/src/nextPage.js:153355:53)"," at Generator.next (<anonymous>)"," at asyncGeneratorStep (/var/task/src/nextPage.js:153264:103)"," at _next (/var/task/src/nextPage.js:153266:194)"," at processTicksAndRejections (internal/process/task_queues.js:97:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string. Received undefined"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:314:20)"," at processPromiseRejections (internal/process/promises.js:209:33)"," at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
11:22:46 PM: Duration: 805.37 ms Memory Usage: 136 MB
11:22:46 PM: Unknown application error occurred
I can't make much of what's going on, but digging through node_modules it seems the validateString() method mentioned in the logs above belongs to the Next.js library.
Any ideas on whether this is a next issue, next-auth issue, or a next-on-netlify issue?
To Reproduce
Steps to reproduce:
- Navigate to https://next-on-netlify-auth.netlify.app/api/auth/signin
- Enter email
- See error message
The same steps above work without error on localhost (both npm run dev
and netlify dev
).
Here is a repo with the code: https://github.com/zaarheed/next-on-netlify-auth. Run it locally or deploy to Netlify. Remember to add environment variables in .env (example provided) or in the Netlify dashboard.
Versions
"next": "10.0.6"
"next-auth": "3.4.1"
"next-on-netlify": "2.8.7"