-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not support CommonJS #7
Comments
what is the solution? |
You can use a dynamic import, if import("..") doesn't work for you: const importDynamic = new Function('modulePath', 'return import(modulePath)') And then use it in a async function, like so: async function main() {
const importDynamic = new Function('modulePath', 'return import(modulePath)')
const {Bard} = await importDynamic("googlebard")
} |
I hope this help! let cookies = process.env.BARD_COOKIES;
let importDynamic = new Function('modulePath', 'return import(modulePath)')
const { Bard } = await importDynamic("googlebard")
let bot = new Bard(cookies);
let response = await bot.ask(messageContent, conversationID); |
Thanks, solved |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/home/runner/bard/index.js:1
const Bard = require('googlebard')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/bard/node_modules/googlebard/dist/index.js from /home/runner/bard/index.js not supported.
Instead change the require of /home/runner/bard/node_modules/googlebard/dist/index.js in /home/runner/bard/index.js to a dynamic import() which is available in all CommonJS modules.
at Object. (/home/runner/bard/index.js:1:14) {
code: 'ERR_REQUIRE_ESM'
}
The text was updated successfully, but these errors were encountered: