auth0 / node-auth0

Node.js client library for the Auth0 platform.
MIT License
620 stars 303 forks source link

Webpack failure TypeError: hexoid is not a function #798

Closed maryamaljanabi closed 1 year ago

maryamaljanabi commented 1 year ago

Describe the problem

When running my nodejs serverless application that uses anything from auth0, I get the following error:

TypeError: hexoid is not a function
    at Object.../../formidable/src/Formidable.js (/***/***/***/project-name/.webpack/service/handlers/auth0-file.js:111306:18)

What was the expected behavior?

The application should not throw an error and accessing the features of auth0 package should be accessed without a problem.

Reproduction

Environment

adamjmcgrath commented 1 year ago

Hi @maryamaljanabi - thanks for raising this

What version of Formidable are you using in your project, can you do yarn why formidable and share the result?

maryamaljanabi commented 1 year ago

@adamjmcgrath Thanks for your response. I'm not using Formidable directly but some of my packages depend on it. Here's the output of yarn why formidable:

=> Found "formidable@2.1.1"
info Reasons this module exists
   - "_project_#(my-folder-name)#auth0#rest-facade#superagent" depends on it
   - Hoisted from "_project_#(my-folder-name)#auth0#rest-facade#superagent#formidable"
info Disk size without dependencies: "176KB"
info Disk size with unique dependencies: "532KB"
info Disk size with transitive dependencies: "1.12MB"
info Number of shared dependencies: 10
adamjmcgrath commented 1 year ago

Hi @maryamaljanabi - could you share a repo that demonstrates the issue? I'm not able to reproduce it with the steps you've shared

maryamaljanabi commented 1 year ago

Hi @adamjmcgrath thanks a lot for responding again. I could reproduce this issue on both Windows and Ubuntu. I'd appreciate any feedback on how to solve this. I get the error when running yarn start and calling any endpoint that uses auth0.

bxjw commented 1 year ago

I also am having this problem. We are using 3.2.0 and run into the exact same problem on AWS Lambda, after disabling superagent-proxy like the Readme says.

bxjw commented 1 year ago

I figured out a workaround @maryamaljanabi: https://github.com/auth0/node-auth0/issues/657#issuecomment-928083729 specifically what NotMyself commented on Sep 27, 2021.

maryamaljanabi commented 1 year ago

Thank you for mentioning that @bxjw. Since I'm using serverless-bundle package, I can't configure webpack but I found an option to disable Formidable package in the serverless-bundle settings based on the solution you suggested.

maryamaljanabi commented 1 year ago

For anyone struggling with this issue while using serverless-bundle, I had to disable Formidable in the bundle settings. Just include the following in the custom section of your serverless.yml file:

custom:
  bundle:
    aliases:
      - formidable: false

Another solution is to downgrade superagent package from version 7 to 6 according to this solution https://github.com/node-formidable/formidable/issues/337#issuecomment-1118348077. In my case, superagent is a dependency of a dependency and I'm not using it directly so I had to downgrade it using yarn resolutions. I added the following to the package.json file:

  "resolutions": {
    "superagent": "6.0.0"
  }

I ended up going with the first solution and just disabling Formidable in serverless-bundle

Update: Disabling Formidable only worked offline but I encountered issues when deploying the serverless app. I solved it by adding Formidable and superagent as externals instead:

custom:
  bundle:
    externals:
      - superagent-proxy
      - formidable
Max101 commented 1 year ago

Why has this issue been closed? This library clearly does not work properly in a node environemnt in a aws Lambda. So many issues with node-auth0 to actually work in node its incredible. A few months ago we were dealing with Superagent-proxy issues, got around that and now this which fine for the people who have control over Webpack configs you can solve it, but what for the res of us? This clearly is not a stable library given all the unnecessary issues developers need to deal with

ryanmz1 commented 12 months ago

I encountered issues:

  1. Can't resolve 'superagent-proxy'
  2. hexoid is not a function

finally #828 works fine for me(sls v1.67, Nodejs14), and watch out the serverless-bundle version by the way, lower version may cause failure.

Reference: https://github.com/AnomalyInnovations/serverless-nodejs-starter/compare/master...adamjmcgrath:serverless-nodejs-starter:master

Tryd0g0lik commented 8 months ago

I figured out a workaround @maryamaljanabi: #657 (comment) specifically what NotMyself commented on Sep 27, 2021.

thanks for this a link


i fixed this ERORR: [!hexoid is not a function]

kingcaubalejo commented 4 months ago

i encountered the same issue when I used the formidable