简体   繁体   中英

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.

I have built out an app in 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.

The production server is running on linux.

package.json file below incase it helps.

{
  "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 .

Node.js v4.0.0 contains V8 v4.5, the same version of V8 shipping with the Chrome web browser today.
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.

If you are using an older version of Node.js on your production server, please consider upgrading it to a more recent version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM