Azure Node.js Web应用程序的自定义启动命令(ES2015 / babel)?

我正在将ES2015 node.js应用程序从Heroku迁移到Azure。

在Heroku上运行的当前启动命令是

"start": "./node_modules/babel-cli/bin/babel-node.js index.js" 

但是,在Azure上,我越来越

package.json中的启动命令“./node_modules/babel-cli/bin/babel-node.js index.js”无效。 请使用格式“node <script relative path>”。

这表明Azure仅支持用于npm start vanilla节点。

我知道在生产上运行babel-node并不理想,但我希望能够直接迁移。

三个需要重新devise的选项是:

  1. 使用gulp工作stream预编译ES2015: https : //github.com/christopheranderson/azure-node-es2015-example
  2. 使用bash工作stream预编译ES2015: http : //www.wintellect.com/devcenter/dbaskin/deploying-an-es6-jspm-nodejs-application-to-azure
  3. 使用babel-register阿拉[评论链接]。

我怀疑选项3将是最简单的,但检查是否有人遇到过类似的问题,并设法在Azure上直接在npm start babel-node

根据您的问题,请修改您的start npm脚本到Azure Web Apps上的node ./node_modules/babel-cli/bin/babel-node.js index.js

这里是testingpackage.json的内容:

 { "name": "website", "description": "A basic website", "version": "1.0.0", "engines": { "node": "5.9.1", "npm": "3.7.3" }, "scripts": { "start": "node ./node_modules/babel-cli/bin/babel-node.js index.js" }, "dependencies": { "babel-preset-es2015": "^6.6.0", "babel-cli": "^6.0.0" } } 

同时,如果您需要更高级的Node.js版本,则可以在package.json指定,请参阅https://azure.microsoft.com/zh-CN/documentation/articles/nodejs-specify-node-version-azure-apps /更多。

正如Gary所说,你需要使用下面的命令来更新你的package.json

 "scripts": { "start": "node ./node_modules/babel-cli/bin/babel-node.js index.js" }