auth0 / node-auth0

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

ReferenceError: fetch is not defined #1000

Closed amanbabbar-kipl closed 2 months ago

amanbabbar-kipl commented 2 months ago

Checklist

Description

I have a Nestjs application and I install the auth0 package. it works on my local Windows machine and ubuntu server with Node 20.6.0 but not working with Nodejs 18 or Node 20.9.0. I see the following stack trace:

The error showing the path auth0/src/lib/runtime.ts but on installing the auth0 package I get only dist folder. there is no src folder for auth0

ReferenceError: fetch is not defined
    at new BaseAPI (/var/node/nestjs-demo/api/node_modules/auth0/src/lib/runtime.ts:34:44)\n
    at new BaseAuthAPI (/var/node/nestjs-demo/api/node_modules/auth0/src/auth/base-auth-api.ts:97:5)
    at new Database (/var/node/nestjs-demo/api/node_modules/auth0/src/auth/database.ts:120:1)
    at new AuthenticationClient (/var/node/nestjs-demo/api/node_modules/auth0/src/auth/index.ts:18:21)
    at new TokenProvider (/var/node/nestjs-demo/api/node_modules/auth0/src/management/token-provider.ts:23:33)
    at new TokenProviderMiddleware (/var/node/nestjs-demo/api/node_modules/auth0/src/management/token-provider-middleware.ts:20:28)
    at new ManagementClient (/var/node/nestjs-demo/api/node_modules/auth0/src/management/management-client.ts:73:9)
    at new AuthService (/var/node/nestjs-demo/api/src/modules/auth/auth.service.ts:11:29)
    at Injector.instantiateClass (/var/node/nestjs-demo/api/node_modules/@nestjs/core/injector/injector.js:365:19)
    at callback (/var/node/nestjs-demo/api/node_modules/@nestjs/core/injector/injector.js:65:45)

Reproduction

  1. Create a Nest js application
  2. create a service to Initalise ManagementClient using domain, client id and secret params

auth0-fetch-error-Capture

Additional context

No response

node-auth0 version

4.3.1

Node.js version

20.6.0

frederikprijck commented 2 months ago

Fetch is a built in thing in node. If it's not available, you need to look into your local environment. There is nothing our SDK can do about that.