【问题标题】:Using Node v4.0 for Windows Azure Web App使用适用于 Windows Azure Web 应用程序的 Node v4.0
【发布时间】:2015-09-23 13:39:31
【问题描述】:

我正在使用 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 应用程序中运行的节点版本。从 Azure 的控制台,我再次运行 node -v。现在我看到了,“v0.10.32”。

如何为 Microsoft Azure Web 应用程序运行 Node 4.0?

【问题讨论】:

    标签: node.js azure


    【解决方案1】:

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

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

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

    【讨论】:

    • 哇!这为我节省了很多时间。我走的是一条完全不同的路线。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 2018-07-29
    • 2016-06-19
    • 2016-03-24
    相关资源
    最近更新 更多