node.js - 将 Node v4.0 用于 Windows Azure Web 应用程序

标签 node.js azure

我正在使用 Node.js 构建一个 Web 应用程序。当 Node 4.0 版本发布时我就开始了。当我在本地计算机上运行 node -v 时,我看到:“v4.0.0”。我将该网站部署为 Microsoft Azure Web 应用程序。但是,这引入了 500 错误。

我查看了日志,看到以下内容:

Wed Sep 23 2015 13:29:20 GMT+0000 (Coordinated Universal Time): Unaught exception: SyntaxError: Unexpected reserved word
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:\home\site\wwwroot\routes\index.js:4:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

相关行使用了 class 关键字,这在 Node 4.0 中是允许的。这促使我检查 Azure Web 应用程序中运行的 Node 版本。我从 Azure 的控制台再次运行 node -v。现在我看到“v0.10.32”。

如何为 Microsoft Azure Web App 运行 Node 4.0?

最佳答案

在 package.json 的“engines”指令中指定版本

{
  "engines":{"node":4.0.0}
}

有关在此处指定版本的更多信息:https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/

关于node.js - 将 Node v4.0 用于 Windows Azure Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32741237/

相关文章:

node.js - 如何解决 - 首次连接时出现 MongoError : failed to connect to server [zzzzz. mlab.com:xxxx]

Azure SQL 数据仓库 : No catalog entry found for partition ID <id> in database <id>. 元数据不一致。运行 DBCC CHECKDB

azure - 使用 Azure 服务总线时 SignalR 无法连接

python - Azure Powershell 中出现异常 'File not found' pscloudshell 错误

javascript - 为什么 Date().toLocaleString 在 nodejs 中返回的值与浏览器不同?

javascript - 使用 eval() 评估学生程序员的代码。安全漏洞?

javascript - 使用默认值解构嵌套对象,包括 Node

javascript - 如何使用nodejs readline库通过返回函数从stdin读取

azure - 使用已删除的名称创建 Azure API 管理会导致名称 "already in use"错误

java - 如何下载azure函数应用程序的代码