auth0-deploy-cli
auth0-deploy-cli copied to clipboard
Auth0 cli dependencies error
Checklist
- [X] I have looked into the README and have not found a suitable solution or answer.
- [X] I have looked into the documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have upgraded to the latest version of this tool and the issue still persists.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
Description
Hello, We are using auth0-cli as a node-module to export the data. We have tried with [7.20.0][7.19.0]....[7.11.0] versions, but same error.
Environment WSL on windows, Ubuntu-22.04 Node v18.16.0 Using Typescript Version 4.9.5 Using Auth0-cli in AWS Lambda (import { dump } from 'auth0-deploy-cli';)
Package.json "auth0": "4.0.1", "auth0-deploy-cli": "7.20.0"
Lambda code import { Connection, ManagementClient, PostUsersExportsRequest, GetOrganizationMemberRoles200ResponseOneOfInner, } from "auth0"; import { dump } from 'auth0-deploy-cli';
//start dump clients dump({ output_folder: '/tmp/auth0-config/export/directory"', format: 'directory', config: { AUTH0_DOMAIN: secrets.domain, AUTH0_CLIENT_ID: secrets.client_id, AUTH0_CLIENT_SECRET: secrets.client_secret, }, }) .then(() => { console.log('Auth0 configuration export successful'); }) .catch((err) => { console.log('Error during Auth0 configuration export:', err); }); //end dump
Steps:
npm install
npm run build "build": npm run functions:build, "functions:build": "tsc -p functions",
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs.NodejsFunction.html Node.js Lambda function bundled using esbuild.
suhailt@GTKNZ072:~/Project/platform-auth0$ npm run build
[email protected] build npm run functions:build
[email protected] functions:build tsc -p functions
node_modules/promise-pool-executor/index.d.ts:5:31 - error TS2305: Module '"promise-batcher"' has no exported member 'BatcherToken'.
5 export { BATCHER_RETRY_TOKEN, BatcherToken, BatchingResult } from "promise-batcher"; ~~~~~~~~~~~~
Found 1 error in node_modules/promise-pool-executor/index.d.ts:5 `
Expectation
Able to deploy the lambda with the auth0-cli.
Reproduction
With node Node v18.16.0 Using Typescript Version 4.9.5 Use the latest 7.20.0
Deploy the AWS lambda npx cdk deploy <Stack>
Deploy CLI version
7.20.0
Node version
v18.16.0
@Gentracker1 can you reproduce this locally? Or only on lambda?
If only on lambda, are you using the default image for AWS Node? If not, is it an image we can use to reproduce?
I did write a small test to try it locally and couldn't reproduce the error. I'm trying to get as close to your setup as possible. The lambda environment is my main unknown. I'm happy to dig in more if you could get me that info.
Updated with the more info and updated the auth0/auth0-cli to the latest version. The error with the latest version is at npm run build.
We are using the WSL Ubuntu with AWS CDK,
@m3talsmith I have updated the error desc, we are using the latest auth0-cli. Thanks
@Gentracker1 I was able to reproduce the promise-batcher error. Will have a work around for you soon.
@Gentracker1 what happens if you add this to your dependencies:
"promise-batcher": "1.0.1"
Thanks @m3talsmith .
After installing promise-batcher, I was able to build and deploy the lambda.
On executing the lambda, it gives the below error.
{ "errorType": "TypeError", "errorMessage": "hexoid is not a function", "trace": [ "TypeError: hexoid is not a function", " at node_modules/formidable/src/Formidable.js (/var/task/index.js:68166:20)", " at __require (/var/task/index.js:12:50)", " at node_modules/formidable/src/index.js (/var/task/index.js:69025:22)", " at __require (/var/task/index.js:12:50)", " at node_modules/superagent/lib/node/index.js (/var/task/index.js:73799:22)", " at __require (/var/task/index.js:12:50)", " at node_modules/rest-facade/src/Client.js (/var/task/index.js:116198:19)", " at __require (/var/task/index.js:12:50)", " at node_modules/rest-facade/src/index.js (/var/task/index.js:116454:15)", " at __require (/var/task/index.js:12:50)" ] }
Found a similar error for "hexoid" is not a function here: https://github.com/auth0/node-auth0/issues/798 Suggestions for a fix there seem to relate to webpack. Not sure how to resolve for AWS CDK/NodeJsFunction which is bundling via esbuild.
Overriding the superagent version for rest-facade in package.json seems to workaround the problem.
"overrides": {
"rest-facade": {
"superagent": "6.0.0"
}
}
Not an ideal solution to override dependencies though.
Tracking down hexoid and superagent errors now @Gentracker1 and @matthewhgentrack
This definitely comes down to transitive dependencies of node-auth. Specifically, it comes down to formidable via superagent as @matthewhgentrack points out. A workaround seems to be to downgrade superagent or save the latest formidable to your npm packages.
The fix is simple: Don't add add an old promise-batcher version to your direct dependencies. Do an override of the peer dependency itself:
"overrides": { "promise-pool-executor": { "promise-batcher": "1.0.2" } }
To avoid the hexoid issue, just make sure to use the newest auth0 3.* version (v3.7.2).