I’m using the Auth0 package in a netlify function.
var AuthenticationClient = require('auth0').AuthenticationClient;
var auth0 = new AuthenticationClient({
domain: '{YOUR_ACCOUNT}.auth0.com',
clientId: '{OPTIONAL_CLIENT_ID}'
});
And I’m getting this error
Function invocation failed: TypeError: n is not a function
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.
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.
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!
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…
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.
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: