Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Browserify fails to resolve default node module used within an external package #2077

@Abdullah-03

Description

@Abdullah-03

When the command "browserify main.js -o bundle.js" is run for main.js (see below)

const google = require('googleapis')

async function runSample() {
  const drive = google.drive({
    version: 'v2',
    headers: {
      Authorization: `Bearer authToken`,
    },
  })

  // Make an authorized request to list Drive files.
  const res = await drive.files.list()

  return res
}

runSample().catch(console.error)

it throws the error:

Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'C:\project\process'
required by C:\project\node_modules\googleapis-common\build\src\http2.js

Browserify seems to be looking in the wrong directory for the module, what gives?

These are the imports of the 'node_modules\googleapis-common\build\src\http2.js' file, which uses the node:process module:

Object.defineProperty(exports, "__esModule", { value: true });
exports.closeSession = exports.request = exports.sessions = void 0;
const http2 = require("http2");
const zlib = require("zlib");
const url_1 = require("url");
const qs = require("qs");
const extend = require("extend");
const stream_1 = require("stream");
const util = require("util");
const process = require("process");
const common_1 = require("gaxios/build/src/common");
const { HTTP2_HEADER_CONTENT_ENCODING, HTTP2_HEADER_CONTENT_TYPE, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS, } = http2.constants;
const DEBUG = !!process.env.HTTP2_DEBUG;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions