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

Uncaught ReferenceError: process is not defined #531

Closed
TechyShishy opened this issue Apr 3, 2023 · 1 comment
Closed

Uncaught ReferenceError: process is not defined #531

TechyShishy opened this issue Apr 3, 2023 · 1 comment
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. web

Comments

@TechyShishy
Copy link

  • OS: Windows
  • Node.js version:
  • npm version: 9.5.1
  • gaxios version: 5.1.0-8264dde5be-c3bf9eff00

Steps to reproduce

The following basic code, when run from an environment that doesn't set the process variable properly, produces a ReferenceError:

import "../css/options.css";

import { google } from "googleapis";

document.addEventListener('DOMContentLoaded', async () => {
    try {
        const authToken = await new Promise<string>((resolve, reject) => {
            chrome.identity.getAuthToken({ interactive: true }, (token: string) => {
                if (chrome.runtime.lastError) {
                    reject(chrome.runtime.lastError.message);
                } else {
                    resolve(token);
                }
            });
        });
        var drive = google.drive({ version: 'v3', auth: authToken });
        console.log(await drive.about.get({ fields: 'user' }));
    } catch (error) {
        console.error("failed to get auth: ", error);
    }
});

Running the above code produces this error:

Uncaught ReferenceError: process is not defined
    at loadProxy (googleapis.js?v=ec7946eb:1307:21)
    at .yarn/cache/gaxios-npm-5.1.0-8264dde5be-c3bf9eff00.zip/node_modules/gaxios/build/src/gaxios.js (googleapis.js?v=ec7946eb:1313:5)
    at __require (chunk-RSJERJUL.js?v=ec7946eb:3:50)
    at .yarn/cache/gaxios-npm-5.1.0-8264dde5be-c3bf9eff00.zip/node_modules/gaxios/build/src/index.js (googleapis.js?v=ec7946eb:1541:20)
    at __require (chunk-RSJERJUL.js?v=ec7946eb:3:50)
    at .yarn/cache/gcp-metadata-npm-5.2.0-0aeb32e4bc-4e7ed589c8.zip/node_modules/gcp-metadata/build/src/index.js (googleapis.js?v=ec7946eb:3545:20)
    at __require (chunk-RSJERJUL.js?v=ec7946eb:3:50)
    at .yarn/cache/google-auth-library-npm-8.7.0-5b2f8eb41a-978d1c5f76.zip/node_modules/google-auth-library/build/src/auth/googleauth.js (googleapis.js?v=ec7946eb:27034:23)
    at __require (chunk-RSJERJUL.js?v=ec7946eb:3:50)
    at .yarn/cache/google-auth-library-npm-8.7.0-5b2f8eb41a-978d1c5f76.zip/node_modules/google-auth-library/build/src/index.js (googleapis.js?v=ec7946eb:27886:24)

One common environment that doesn't have a process variable is inside chrome extensions, which can't use the gapi.js code, as ManifestV3 doesn't allow execution of remote code.

@TechyShishy TechyShishy added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 3, 2023
@danielbankhead danielbankhead self-assigned this Apr 8, 2023
@danielbankhead danielbankhead added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. web and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 8, 2023
@danielbankhead
Copy link
Member

@TechyShishy,

At this time, this library is designed for Node.js. If you're interested in running in the browser, consider using webpack (ref: #337)

@danielbankhead danielbankhead closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants