Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda