title: I can't use an API on Javascript, Might be related to node.js and such
body: <ol>
  <li><strong>Okay so I'm new to Javascript, please keep that in mind, and I'm working from a directory in my home computer, like, the web is not hosted in a server or anything, I've never done that</strong></li>
  </ol>
  <p>I've been trying to work with a Google Translate API (<a href="https://github.com/matheuss/google-translate-api" rel="nofollow noreferrer">https://github.com/matheuss/google-translate-api</a>)</p>
  <p>I literally just copied the first example, and the console log on my web said something like</p>
  <blockquote>
  <p>Uncaught ReferenceError: require is not defined     file:///C:/Users/User/Desktop/web/script.js:11</p>
  </blockquote>
  <p>For context, here's the line</p>
  <p><code>    const translate = require('google-translate-api');</code></p>
  <p><strong>Besides that</strong> whenever I try and install the api using the given Command on the Github page, I get some errors</p>
  <blockquote>
  <p>npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\User\package.json'</p>
  </blockquote>
  <p>also</p>
  <blockquote>
  <p>$npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\User\package.json'<br />
  $npm WARN User No description<br />
  $npm WARN User No repository field.
  $npm WARN User No README data
  $npm WARN User No license field.</p>
  </blockquote>
  <p>and</p>
  <blockquote>
  <p>$found 6 vulnerabilities (2 high, 4 critical)</p>
  </blockquote>
  <p>When dealing with it by using <em><strong>$npm audit</strong></em> all I get is</p>
  <blockquote>
  <p>$npm ERR! code EAUDITNOPJSON</p>
  </blockquote>
  <blockquote>
  <p>$npm ERR! audit No package.json found: Cannot audit a project without a package.json
  json
  $npm ERR! A complete log of this run can be found in:</p>
  </blockquote>
  <blockquote>
  <p>$npm ERR!     C:\Users\User\AppData\Roaming\npm-cache_logs\2020-07-09T16_40_06_962Z-debug.log</p>
  </blockquote>
  <p>and the same goes for <em><strong>$npm audit fix</strong></em></p>
  <ol start="2">
  <li>I've tried to follow the guidelines I found on Github, even downloading the files directly to my project's folder (again, I don't really know if that would be useful at all), and nothing worked. I have GitHub on my PC, Git, nodejs, npmjs etc. and nothing works.</li>
  </ol>
  <p>I've also used <em><strong>$npm init</strong></em> as sugested below (which created a package.json file) and then installed the API, but the console log part where it says</p>
  <blockquote>
  <p>Uncaught ReferenceError: require is not defined
   file:///C:/Users/User/Desktop/web/script.js:11</p>
  </blockquote>
  <p>still happens</p>
  <p>I've read somewhere, however, that I should use something like browsify because the problem might be related to the fact that my web isn't hosted on a server (again, idk the technical words, but I'm trying to explain my situation as best as I can), but maybe I'm just making a really simple mistake.</p>
  <ol start="3">
  <li>Here's some code that I copied directly from the API's Github page
  (textoEntrada is just some text I put inside the thing from an input text box)</li>
  </ol>
  <pre><code>    translate(textoEntrada, {to: 'en'})
      .then(res =&gt; {
      console.l`enter code here`og(res.text);
      console.log(res.from.language.iso);
      }).catch(err =&gt; {
      console.error(err);
      });```
  </code></pre>