EvanZhouDev / bard-ai

A lightweight library to access Google Bard.
https://www.npmjs.com/package/bard-ai
GNU General Public License v3.0
117 stars 31 forks source link

ISSUE FROM NODE.JS #62

Closed Helohhhh closed 1 year ago

Helohhhh commented 1 year ago

Sorry, but i am just starting to code in Javascript. I get this error while using the command'''node script.js''' and i get this error:

import Bard, { askAI } from "bard-ai";
^^^^^^

SyntaxError: Cannot use import statement outside a module
←[90m    at Module._compile (internal/modules/cjs/loader.js:892:18)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:812:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:724:14)←[39m
←[90m    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)←[39m
←[90m    at internal/main/run_main_module.js:17:11←[3

It would be great if you help me

ThatXliner commented 1 year ago

rename it to script.mjs

EvanZhouDev commented 1 year ago

Or just set type: "module" in package.json :)

ThatXliner commented 1 year ago

https://nodejs.org/api/esm.html#enabling