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

Can't resolve 'superagent-proxy' #874

Closed
5 tasks done
naishe opened this issue Jun 25, 2023 · 7 comments
Closed
5 tasks done

Can't resolve 'superagent-proxy' #874

naishe opened this issue Jun 25, 2023 · 7 comments
Labels
bug This points to a verified bug in the code

Comments

@naishe
Copy link

naishe commented Jun 25, 2023

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I use barebones NextJS 13, and this is what I use

  const auth0ManagementClient = new ManagementClient({
    clientId: env.AUTH0_MANAGEMENT_CLIENT_ID,
    clientSecret: env.AUTH0_MANAGEMENT_CLIENT_SECRET,
    domain: env.AUTH0_MANAGEMENT_DOMAIN,
  });
    "auth0": "^3.4.0",

It's suggested here: #663 (comment) to install a deprecated dependency. This is a new project, and I don't want to incorporate a dependency which is deprecated and has 50 dependencies!

❯ p add [email protected] 
 WARN  deprecated [email protected]: Please upgrade to v7.0.2+ of superagent.  We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing.  See the releases tab for more information at <https://github.com/visionmedia/superagent/releases>.
 WARN  deprecated [email protected]: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
Packages: +50
++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 729, reused 721, downloaded 0, added 0, done

dependencies:
+ rest-facade 1.13.0 (1.16.4 is available)

Any resolution?

Reproduction

In nextJS route try using this code

export async function createUser(email: string) {
  const auth0ManagementClient = new ManagementClient({
    clientId: env.AUTH0_MANAGEMENT_CLIENT_ID,
    clientSecret: env.AUTH0_MANAGEMENT_CLIENT_SECRET,
    domain: env.AUTH0_MANAGEMENT_DOMAIN
  });

  const password = generatePassword.generate({
    length: 10,
    numbers: true,
    symbols: true,
    uppercase: true,
    strict: true,
  });

  return auth0ManagementClient.createUser({
    email,
    connection: "Username-Password-Authentication",
    password,
  });
}

Additional context

No response

node-auth0 version

^3.4.0

Node.js version

v20.2.0

@naishe naishe added the bug This points to a verified bug in the code label Jun 25, 2023
@frederikprijck
Copy link
Member

frederikprijck commented Jun 26, 2023

Thanks for reaching out.

Can you try uninstalling that version of rest-facade, but stick with what our SDK provides (which should be ^1.16.3 for rest-facade, resolving to the latest version (1.16.4))?

Would it be resolved if you then npm i superagent-proxy, which should install v7, the non-deprecated version.

Let me know if that wouldn't work.

@naishe
Copy link
Author

naishe commented Jun 26, 2023

Thanks for the reply. Installing the latest version of rest-facade and then installing the latest superagent-proxy does seem work, but the logs are filled with ugly warning messages but I really don't want to add formidable and/or coffee-script as dependency. :(

The superagent-proxy's latest version is 3.0.0 at the moment.

This is what polluting the log files now.

warn  - ./node_modules/.pnpm/[email protected]/node_modules/formidable/src/Formidable.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/formidable/src/Formidable.js
./node_modules/.pnpm/[email protected]/node_modules/formidable/src/index.js
./node_modules/.pnpm/[email protected]/node_modules/superagent/lib/node/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rest-facade/src/Client.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rest-facade/src/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/auth0/src/management/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/auth0/src/index.js
./[-- snip --]/auth0Utils.ts
./app/api/[-- snip --]/route.ts

./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/compiler.js
Module not found: Can't resolve 'coffee-script' in '/Users/[--snip--]/node_modules/.pnpm/[email protected]/node_modules/vm2/lib'

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/compiler.js
./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/script.js
./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/main.js
./node_modules/.pnpm/[email protected]/node_modules/vm2/index.js
./node_modules/.pnpm/[email protected]/node_modules/degenerator/dist/src/index.js
./node_modules/.pnpm/[email protected]/node_modules/pac-resolver/dist/index.js
./node_modules/.pnpm/[email protected]/node_modules/pac-proxy-agent/dist/agent.js
./node_modules/.pnpm/[email protected]/node_modules/pac-proxy-agent/dist/index.js
./node_modules/.pnpm/[email protected]/node_modules/proxy-agent/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/superagent-proxy/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rest-facade/src/Client.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rest-facade/src/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/auth0/src/management/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/auth0/src/index.js
./[-- snip --]/auth0Utils.ts
./app/api/[-- snip --]/route.ts

./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/resolver-compat.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/resolver-compat.js
./node_modules/.pnpm/[email protected]/node_modules/vm2/lib/main.js
./node_modules/.pnpm/[email protected]/node_modules/vm2/index.js
./node_modules/.pnpm/[email protected]/node_modules/degenerator/dist/src/index.js
./node_modules/.pnpm/[email protected]/node_modules/pac-resolver/dist/index.js
./node_modules/.pnpm/[email protected]/node_modules/pac-proxy-agent/dist/agent.js
./node_modules/.pnpm/[email protected]/node_modules/pac-proxy-agent/dist/index.js
./node_modules/.pnpm/[email protected]/node_modules/proxy-agent/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/superagent-proxy/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rest-facade/src/Client.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/rest-facade/src/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/auth0/src/management/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/auth0/src/index.js
./[-- snip --]/auth0Utils.ts
./app/api/[-- snip --]/route.ts

@frederikprijck
Copy link
Member

Installing the latest version of rest-facade and then installing the latest superagent-proxy does seem work

Installing our SDK in a new project should bring in the latest version of rest-facade. Maybe you have an older version because of the manual npm install you did ?

I understand what's been called our, but that's not part of our SDK directly, but a consequence of using rest-facade.

We do have a beta version of our SDK available that no longer uses rest-facade, or it's underlying superagent-proxy, so we are aware of the issues and have been actively working on replacing it.

Feel free to try it out and provide feedback, and know that any workaround you have to do now, is temporary while we work towards GA.

@naishe
Copy link
Author

naishe commented Jun 26, 2023

I am excited to learn that this pain is temporary. 👍
I performed a clean install but the formidable and coffee-script warnings stay. The user creation works. 🤞 I am putting in the staging. Worst case, I will write a couple of simple fetch calls to Auth0 endpoints to get my job done; but I am hopeful.
Thanks.

@naishe
Copy link
Author

naishe commented Jun 26, 2023

@frederikprijck -- I have tested beta. It's better but not without flaws. One thing that I noticed that it uses an older node-fetch library. The current version is 3.3.1 while auth0@beta seems to be using 2.6.11. However, my bigger concern is this warning message in beta

warn  - ./node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/Users/[--snip--]/node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js
./node_modules/.pnpm/[email protected]/node_modules/auth0/dist/cjs/lib/runtime.js
./node_modules/.pnpm/[email protected]/node_modules/auth0/dist/cjs/auth/database.js
./node_modules/.pnpm/[email protected]/node_modules/auth0/dist/cjs/auth/index.js
./node_modules/.pnpm/[email protected]/node_modules/auth0/dist/cjs/index.js
./[-- snip --]/auth0Utils.ts

@adamjmcgrath
Copy link
Contributor

Hi @naishe - the latest v4 beta uses node-fetch@3 which doesn't have the "Can't resolve 'encoding'" warning on Next.js

More info on the Beta here #859

@ryanmz1
Copy link

ryanmz1 commented Jul 11, 2023

#798 (comment) may be helpful for the issue, if you have to use v3, as v4 beta requires >= Nodejs16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

4 participants