Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack failure TypeError: hexoid is not a function #798

Closed
maryamaljanabi opened this issue Mar 24, 2023 · 12 comments
Closed

Webpack failure TypeError: hexoid is not a function #798

maryamaljanabi opened this issue Mar 24, 2023 · 12 comments
Labels

Comments

@maryamaljanabi
Copy link

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

  • yarn add auth0 @types/auth0
  • yarn start
  • Request the endpoint that uses anything from auth0

Environment

  • Version of this library used: 3.3.0 (also tried previous versions up till 2.2.24)
  • Which framework are you using, if applicable: nodejs serverless application (no framework)
  • Other modules/plugins/libraries that might be involved: the issue seems to be coming from Formidable and Superagent which auth0 depends on (I'm not using them myself)
  • Any other relevant information you think would be useful:
    It's worth mentioning these versions that I'm using:
  • @types/auth0: 3.3.0
  • serverless: 2.66.0
  • serverless-bundle: 5.0.2
  • serverless-offline: 8.2.0
  • aws-sdk: 2.684.0
  • nodejs tried all these versions but the error didn't go away (14.19.0, 16.17.0, 18.12.0)
@adamjmcgrath
Copy link
Contributor

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
Copy link
Author

@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
Copy link
Contributor

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
Copy link
Author

maryamaljanabi commented Mar 29, 2023

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
Copy link

bxjw commented Mar 29, 2023

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
Copy link

bxjw commented Mar 29, 2023

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

@maryamaljanabi
Copy link
Author

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
Copy link
Author

maryamaljanabi commented Apr 3, 2023

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 node-formidable/formidable#337 (comment).
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
Copy link

Max101 commented May 11, 2023

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
Copy link

ryanmz1 commented Jul 11, 2023

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: AnomalyInnovations/serverless-nodejs-starter@master...adamjmcgrath:serverless-nodejs-starter:master

@Tryd0g0lik
Copy link

Tryd0g0lik commented Oct 13, 2023

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
Copy link

i encountered the same issue when I used the formidable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants