Use Auth0 library in Netlify functions

I’m using the Auth0 package in a netlify function.

var AuthenticationClient = require('auth0').AuthenticationClient;
var auth0 = new AuthenticationClient({
  domain: '{YOUR_ACCOUNT}',
  clientId: '{OPTIONAL_CLIENT_ID}'

And I’m getting this error

Function invocation failed: TypeError: n is not a function

Any advice?

Can you provide more info? What does the calling lambda look like? Are you using netlify dev? Does the issue persist on deployment?

I’d wager that if you aren’t using netlify dev, doing so would resolve the problem.

Semi-related discussion here:


Hi @nonissue,

I’ve got it working, partially :sleepy:

Came across that discussion last night while I was digging for information about it, Thanks for the link.

I’m using "build:lambda": "netlify-lambda -c ./webpack.functions.js build ./src/functions" which builds the functions. The problem appears to be present because some modules were created without the intention to be bundled. :nerd:

However, when I run the netlify dev command in my terminal, netlify-lambda is not being detected and the functions are not being built when I run that command.

So I have to perform this build step manually. :hot_face:

When I replace "build:lambda": "netlify-lambda -c ./webpack.functions.js build ./src/functions" with "build:lambda": "netlify-lambda build ./src/functions" in my package.json script netlify dev detects the build tool. And the error is back.

How can I use netlify dev with the custom ./webpack.functions.js file using netlify-lambda -c and make it hot reload when I change files in ./src/functions/ ?

Hi @berni, you shouldn’t have to actually bundle your dependencies. You can count on zip it and ship it to zip your function and it’s dependencies in production. However, it should still run locally since whether it’s bundled or not doesn’t matter for local development unless your function requires a build step (if you’re using babel, or typescript, etc.).

Is your repo public? if so, please link to the function. Thanks!

Hi @futuregerald,

Thanks for the info. It’s private. And I’ll only run it locally.

Can you clarify what you will only run locally? Also, if you don’t need to bundle in prodution, why are you bundling locally? I’m trying to understand why you need to use netlify-lambda in this case. This would be easier if you were able to share the function code…

@futuregerald that may be a good point.

I’m using Netlify dev. But I need to run a custom webpack plugin include which bundles npm libraries that were not developed in a way that would allow them to be bundled into my serverless functions when run locally.

The reason for this is the error I listed in my first post. Which is the problem in the function code.

Get back to me with your opinion on this.


Hmm, I don’t think running locally to test is probably something is something we’ll necessarily get to the bottom of in our community (or even in our helpdesk), Berni - we do have to be able to see a problem ourselves to debug it, and your source code is not something we can usually help debug anyway.

So, I’d suggest filing a bug on the CLI here with your repro code and the developers of it may be able to take a look sometime:

Hi @fool, I think our wires got crossed.

The NPM library I was using didn’t work when referenced in a Netlify function. So I got the original error I listed in the first post.

After researching the problem, an additional webpack config for Netlify functions was suggested as a solution.

It’s working now. And I’m not referencing bundled files locally. That was a mistake in communication.

Thanks for your help @futuregerald && @fool

1 Like

great! glad you have a fix in place :muscle: