Netlify Dev issue with lambda that uses mongodb driver :- stack trace contains some error about "startswith"

TLDR:- issue resolved! I’m posting to aid others… and myself to remind me in future :wink:

Solution is to run this on your project

netlify link  

This will create ./.netlify/state.json with the url of your actual live site… I assume this is needed to get the url of the real site to do some edge/lambda stuff…
see also x0

This is the stack trace I got before linking the site…

Stack Trace:
TypeError: Cannot read property ‘startsWith’ of undefined
at new l ([some local path]\partFindBatch.js:1:312964)
at t.parseOptions ([some local path]\partFindBatch.js:1:140862)
at new E ([some local path]\partFindBatch.js:1:72269)
at Function.connect ([some local path]\partFindBatch.js:1:74629)
at Module.a ([some local path]\partFindBatch.js:1:385553)
at Object.t.handler ([some local path]\partFindBatch.js:1:715888)
at Object._executeSync ([some user path]\npm\node_modules\netlify-cli\node_modules\lambda-local\build\lambdalocal.js:295:47)
at [some user path]\npm\node_modules\netlify-cli\node_modules\lambda-local\build\lambdalocal.js:95:26
at new Promise ()
at Object.execute ([some user path]\npm\node_modules\netlify-cli\node_modules\lambda-local\build\lambdalocal.js:87:16)

1 Like

Hey there, @mcounsell :wave:

Thank you so much for sharing your solution! This will definitely benefit future forums members.

Happy building :rocket:

1 Like

Hats of to you sir. Thank you for this contribution :netliheart: