Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
cannot call googleapis library inside html

I've been trying to call a simple function (uploadFile(test.txt)) inside an html but I can not call neither my app.js or googleapis library

node.js gives this eror.

Uncaught ReferenceError: uploadFile is not defined
Uncaught Error: Script error for "googleapis"
Uncaught Error: Script error for "path"
Uncaught Error: Script error for "fs"
Uncaught Error: Script error for "googleapis/build/src/apis/deploymentmanager"

path fs and other libraries are called inside app.js using require.js

like this;

requirejs.config({
    baseUrl: 'js/lib',
});
requirejs(['googleapis', 'path', 'fs', 'googleapis/build/src/apis/deploymentmanager'],
function   (google, path,  fs, deploymentmanager) {
..."rest of the code"...}

my index.html file;

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Hello</title>
    <script data-main="js/app.js" src="js/require.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script> 
        uploadFile("test.txt")
    </script>
  </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The arguments you pass to requirejs need to be URLs to AMD modules.

You are passing in the names (not URLs) of CommonJS modules, most of which are Node.js built-ins.

The require function from RequireJS and the require function built into Node.js solve similar problems but are not remotely compatible.

You cannot use RequireJS to load CommonJS modules. You cannot use modules which depend on Node.js features (like fs) in a web browser.


If you want to use a Google API in a browser, then use the library that Google provide for accessing it from a browser. Note that Google does not intend some APIs to be used from a browser at all and you will need to use server-side code to access them.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!