我正在尝试从节点模块'google-translate-api-browser‘导入'setCORS’,但是我得到了错误SyntaxError: Unexpected token {
我已经尝试在我的主脚本文件中指定模块“type=”,但似乎没有效果。
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);
});发布于 2019-08-26 01:42:29
看起来您在错误的路径上安装了模块.在命令行中,try (确保您在主父目录中):
1.rm -rf node-modules
2. npm install --save google-translate-api-browser
3. npm install
4. import the module: import {setCors} from "google-translate-api-browser"
5. Test it outhttps://stackoverflow.com/questions/57648286
复制相似问题