title: Import ipfs in TypeScript
body: <p>Importing and module initialization is generally simple using JavaScript/TypeScript using either <code>require</code> or <code>import</code>. I'm having trouble running the basic example from the JS IPFS <a href="https://js.ipfs.io/#:%7E:text=js-ipfs%20also%20comes%20with%20the%20option%20to%20run,distribute%20updates%20in%20an%20authenticated%20and%20certified%20way." rel="nofollow noreferrer">website</a> to initialize <code>ipfs</code>.</p>
  <p>If I follow the general instructions I get an error: <code>Module parse failed: Cannot use keyword 'await' outside an async function (6:13)</code></p>
  <p>This is the critical code:</p>
  <pre><code>const IPFS = require('ipfs-core');
  const ipfs = await IPFS.create();
  </code></pre>
  <p>If I follow the suggestion to place the <code>ipfs</code> creation in an <code>async</code> function I just delay the inevitable. If I call such a function twice I get an error from <code>Unhandled Rejection (LockExistsError): Lock already being held for file: ipfs/repo.lock</code>.  It seems I could create a hack to test whether <code>ipfs</code> is created or not and initialize it global to a module as null, but that would still be a hack.</p>
  <p>How should I implement or refactor <code>const ipfs = await IPFS.create();</code> without error?</p>