I am trying to import 'setCORS' from a node module 'google-translate-api-browser' but i am getting the error SyntaxError: Unexpected token {
I already tried specifying type="module" in my main script file but it seems to have no effect.
import { setCORS } from "google-translate-api-browser";
//setting up cors-anywhere server address
const translate = setCORS("http://cors-anywhere.herokuapp.com/");
translate(original.textContent(), {to:'ne'})
.then(res => {
console.log(res.text);
})
.catch(err => {
console.log(err);
});
type="module". That is only a thing in HTML script imports, which node doesn't use. How are you running the code?