Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda