I am trying to use google-auth-library with a react app but am getting various errors which seem to indicate missing dependencies. The errors are all in a format similar to this:
Module not found: Error: Can't resolve 'buffer' in '/private/tmp/minimal-example/node_modules/buffer-equal-constant-time'
The error messages include details on how to add a polyfill for the missing dependencies, but even after going through and adding all these polyfills I am unable to use the library. The logs for the development server still show errors for missing files, and the browser console has the following error:
GET http://metadata.google.internal./computeMetadata/v1/instance net::ERR_NAME_NOT_RESOLVED
Steps to reproduce:
- Install Node 16.13.2
- Create a react app
npx create-react-app minimal-example
- Enter directory for the created project
cd minimal-example
- Install google-auth-library
npm install google-auth-library --save
- Add the following code to
./src/App.js
const {GoogleAuth} = require('google-auth-library');
- Start the development server
npm start
- Observe errors
What am I doing wrong?