[英]Why am I getting a syntax error on my node production server build but not my local build?
I hope you can help me . 我希望你能帮助我 。 i'm fairly new to node and am building my first node app. 我对Node相当陌生,正在构建我的第一个Node应用。
I have built out an app in node.js. 我已经在node.js中构建了一个应用程序。 It works fine and as expected when running locally. 在本地运行时,它可以正常运行并按预期运行。
When trying to run it on our internal production server I get an error message. 尝试在内部生产服务器上运行它时,出现错误消息。
It seems to take issue with the opening template literal tag. 开头模板文字标签似乎出现了问题。 The file in question employs a simple module export function. 有问题的文件使用简单的模块导出功能。 I've stripped down the code a bit to make it easier to read. 我将代码简化了一些,以使其更易于阅读。 See below: 见下文:
exports.templateModule = function(markup, edmData) { var template = `<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body></body> </html> `; return template;
I'm using node version v6.11.0. 我正在使用节点版本v6.11.0。
The production server is running on linux. 生产服务器在Linux上运行。
package.json file below incase it helps. 下面的package.json文件可以帮助您。
{
"name": "template",
"version": "0.0.0",
"description": "A simple tempate test.",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"ejs": "^2.5.6",
"ejs-lint": "^0.3.0",
"express": "4.15.2",
"glob": "^7.1.2",
"node-dev": "^3.1.3"
},
"repository": {
"type": "git",
"url": "https://github.com/heroku/node-js-getting-started"
},
"license": "MIT",
"devDependencies": {
"node-dev": "^3.1.3"
}
}
I'll provide any other information you need if I can. 如果可以的话,我会提供您需要的其他信息。
Any help or insight would be much appreciated. 任何帮助或见解将不胜感激。
Thank you 谢谢
Moe 萌
Template strings were added in NodeJS v4.0.0 . 模板字符串已添加到NodeJS v4.0.0中 。
Node.js v4.0.0 contains V8 v4.5, the same version of V8 shipping with the Chrome web browser today. Node.js v4.0.0包含V8 v4.5,与今天的Chrome网络浏览器一起提供的V8版本相同。
This brings with it many bonuses for Node.js users, most notably a raft of new ES6 features that are enabled by default including block scoping, classes, typed arrays (Node's Buffer is now backed by Uint8Array), generators, Promises, Symbols, template strings , collections (Map, Set, etc.) and, new to V8 v4.5, arrow functions. 这为Node.js用户带来了很多好处,最值得注意的是,许多ES6新功能默认启用,包括块作用域,类,类型数组(Node的Buffer现在由Uint8Array支持),生成器,Promises,Symbols, 模板字符串 ,集合(地图,集合等),以及V8 v4.5新增的箭头功能。
If you are using an older version of Node.js on your production server, please consider upgrading it to a more recent version. 如果您在生产服务器上使用的是Node.js的旧版本,请考虑将其升级到最新版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.