Error in code that upload multiple files into a folder at

I’m not good with javascript. I’m trying to upload a few files to as a folder by modifying this example → at main · nftstorage/ · GitHub

Instead of uploading via a form, my files are stored in my PC file system. Below is my js code.

<script type="module">
  import { NFTStorage, File } from ''
  import { fs } from ''

  const endpoint = '' // the default
  const token = 'RDA0NjI0MTIzMTA2Mzgy....' // your API key from

  function log(msg) {
    msg = JSON.stringify(msg, null, 2)
    document.getElementById('out').innerHTML += `${msg}\n`

  document.querySelector('#upload-file-ipfs').addEventListener('click', async (e) => {
	const storage = new NFTStorage({ endpoint, token })
	const cid = await storage.storeDirectory([
		new File([await fs.promises.readFile('metadata.json')], 'metadata.json'),
		new File([await fs.promises.readFile('test.png')], 'test.png'),
	console.log({ cid })
	const status = await storage.status(cid)

But I keep getting this error below.

Uncaught SyntaxError: The requested module '' does not provide an export named 'fs'

I tried replacing ‘’ with ‘npm:fs-extra | Skypack’ and '‘’ and it gives me the same error.

If I remove the curly braces around ‘fs’, I get Uncaught Error: [Package Error] "fs" does not exist. (Imported by "fs-").

Any help is highly appreciated.