简体   繁体   English

为什么在我的节点生产服务器版本上而不是本地版本上出现语法错误?

[英]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.

相关问题 为什么我的本地node.js / express服务器的响应中没有得到JSON对象? - Why am I not getting a JSON object in the response from my local node.js/express server? 为什么在我的无服务器项目上运行 npm 构建时出现此 UnhandledPromiseRejectionWarning 错误? - Why am I getting this UnhandledPromiseRejectionWarning error when running npm build on my serverless project? 在本地服务器上运行parse-server应用程序时,为什么会出现语法错误? - Why do I get syntax error when i am running parse-server app on my local server? 生产版本会覆盖.css节点中的样式 - Production build overrides my style in .css node 为什么我的平均生产应用程序出现 404 错误? - Why am I getting 404 errors on my Mean production app? 为什么我在此 Node JS 代码中收到语法错误? - Why I am getting Syntax error in this Node JS code? 当我从Node服务器进入后端时,为什么会收到404错误的请求? - Why am i getting 404 Bad request when i hit my back end from Node server? 使用Express在本地Node服务器上设置主页时出现错误 - I am having an error setting up my homepage on a local Node server using Express 为什么我在运行时收到此错误:npm run build? - Why am I getting this error when running: npm run build? 在 Windows 的命令行中运行 node server.js 时,为什么会出现语法错误或服务器未定义错误? - Why am I getting a syntax error or server not defined error when running node server.js in command line for windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM