question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Expected `input` to be a `Function` or `Object`, got `undefined`

See original GitHub issue

Hi, I have got the issue while accessing the google sheet API. I tried to Google Sheets API (https://developers.google.com/sheets/api/quickstart/nodejs). And made it as npm package while tried to include the package in new project. i got an issue

Uncaught TypeError: Expected input to be a Function or Object, got undefined at module.exports (index.js?2556:45) at eval (index.js?f447:22) at Object../node_modules/gtoken/build/src/index.js (app.js:5720) at __webpack_require__ (app.js:724) at fn (app.js:101) at eval (jwtclient.js?d465:63) at Object../node_modules/google-auth-library/build/src/auth/jwtclient.js (app.js:3154) at __webpack_require__ (app.js:724) at fn (app.js:101) at Object.eval (googleauth.js?0a40:73)

Please fix the issue Ref: https://stackoverflow.com/questions/54468809/what-is-causing-typeerror-expected-input-to-be-a-function-or-object-issue/54920596#54920596

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
bcoecommented, Apr 4, 2019

@ozydingo 👋 Node.js is a thin layer on top of the V8 JavaScript parser (which is the same JavaScript parser used by Chromium).

Depending on what APIs are used, the same source will sometimes work in Node.js and the browser; there are a few cases where this compatibility can break down:

  1. when Native modules are used in node.js (Node.js can install JavaScript that relies on C++ libraries, which aren’t present in the browser).
  2. when JavaScript relies on Node.js APIs that aren’t available in the browser (fs, http, etc).

I’ve created an issue related to us better documenting these compatibility issues 👍

You can follow the progress here:

https://github.com/googleapis/google-cloud-node/issues/2918

3reactions
erickoledadevrelcommented, Mar 7, 2019

The error seems to be thrown by this line in the gtoken module:

const readFile = pify(fs.readFile);

The error indicates that fs.readFile is undefined. Your stack trace mentioned Webpack, are you by any chance trying to package up this library for use on the client side? That would explain why fs.readFile isn’t defined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is causing TypeError: Expected `input` to be a `Function ...
I'm trying to integrate Firebase Remote Config into my Cordova application to force users to update if they have a minimum version, but ......
Read more >
What is causing TypeError: Expected `input` to be a `Function ...
Coding example for the question What is causing TypeError: Expected `input` to be a `Function` or `Object` issue with gtoken and pify?-Reactjs.
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
Function.prototype.bind() - JavaScript - MDN Web Docs - Mozilla
The bind() method creates a new function that, when called, ... null and undefined will be replaced with the global object, and primitive ......
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
Invoking this “sortUsersByAge” function may be fine if run on a small “users” ... new TypeError('expected a string username, got '+(typeof username)) }...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found