I have a very strange error and I don’t know how to solve it.
I’m trying to publish my system to an Ubuntu 18.04 server.
I installed NODEJS and NPM, the versions that are on the server are:
NODEJS – v10.19.0
NPM – 6.14.4
My backend works all normal on my local machine, after I published it on Ubuntu’s online server it started to get this error:
init = ({ app } = {}) => {
^
SyntaxError: Unexpected token =
at Object.compileFunction (vm.js:406:10)
at Generator.next (<anonymous>)
at Object.<anonymous> (/var/www/backend.io/src/index.js:1)
at Generator.next (<anonymous>)
My file full is :
const i18next = require("i18next");
const Backend = require("i18next-node-fs-backend");
const i18nextMiddleware = require("i18next-express-middleware");
class I18nManager {
t;
currentLang;
init = ({ app } = {}) => {
i18next
.use(Backend)
.use(i18nextMiddleware.LanguageDetector)
.init({
backend: {
loadPath: "locales/{{lng}}/{{ns}}.json",
},
fallbackLng: "en",
preload: ["en", "pt-br"],
})
.then((_t) => (this.t = _t));
if (app) app.use(i18nextMiddleware.handle(i18next));
};
}
const i18n = new I18nManager();
module.exports = {
i18n,
t: (...args) => i18n.t(...args),
currentLang: () => i18next.language,
};