AI Studio generated node.js code refers to non-existent subdirectory

When using node.js code generated by AI Studio

Having developed a prompt using audio file input, and having it work in AI Studio, I gathered the JavaScript code provided and proceeded to run in VSCode IDE on Windows. With a Key obtained, SDK and “npm install @google/generative-ai” run, I get the error
“Package subpath ‘./files’ is not defined by “exports” in "
The AI Studio generated code causing the error is
“const { GoogleAIFileManager } = require(”@google/generative-ai/files”);"
on searching for the relative or absolute path to “\files”, find it does not exist in “node_modules@google\generative-ai”

As a result I cannot upload an audiofile to Gemini.

The API documentation is scant on the audiofile upload documentation (It covers text and image and video.) Any ideas where the missing part of the library is?

1 Like

Hey @Chris_Cook, I would double check the version of the library you are using, I just tested this end to end in a clean environment and it worked for me.

Perhaps create a new local env in your working directory? You should be able to see the “files” folder in the Node modules with a clean install.

1 Like