[英]How Fix deploy nodejs in ubuntu
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.我正在尝试将我的系统发布到 Ubuntu 18.04 服务器。
I installed NODEJS and NPM, the versions that are on the server are: NODEJS - v10.19.0 NPM - 6.14.4我安装了 NODEJS 和 NPM,服务器上的版本是: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:我的后端在我的本地机器上一切正常,在我将它发布到 Ubuntu 的在线服务器上之后,它开始出现这个错误:
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,
};
The syntax you are using requires Node.js 12. 您使用的语法需要 Node.js 12。
Node.js 10 is no longer supported anyway. Node.js 10 无论如何都不再受支持。 Upgrade.
升级。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.