Azure Node.js Web应用程序的自定义启动命令(ES2015/babel)? [英] Custom start-up command for Azure Node.js Web app (ES2015/babel)?
问题描述
我正在将ES2015 node.js应用程序从Heroku迁移到Azure.
I am migrating an ES2015 node.js application from Heroku to Azure.
在Heroku上运行的当前启动命令是
The current start-up command running on Heroku is
"start": "./node_modules/babel-cli/bin/babel-node.js index.js"
但是,在Azure上,我得到了
However, on Azure I am getting
package.json中的无效启动命令"./node_modules/babel-cli/bin/babel-node.js index.js".请使用格式节点<脚本相对路径>".
Invalid start-up command "./node_modules/babel-cli/bin/babel-node.js index.js" in package.json. Please use the format "node <script relative path>".
这表示Azure仅支持npm start
的香草节点.
Which indicates that Azure only supports vanilla node for npm start
.
我知道在生产环境中运行babel-node并不理想,但是我希望进行直接迁移.
I'm aware that running babel-node on production isn't ideal, but I was hoping for a straightforward migration.
需要一些重新架构的三个选项是:
Three options that would require a bit of re-architecting are:
- 使用gulp工作流程预编译ES2015: https://github.com/christopheranderson/azure-node-es2015-example
- 使用bash工作流预编译ES2015:
- Using a gulp workflow to precompile ES2015: https://github.com/christopheranderson/azure-node-es2015-example
- Using a bash workflow to precompile ES2015: http://www.wintellect.com/devcenter/dbaskin/deploying-an-es6-jspm-nodejs-application-to-azure
- Using
babel-register
ala [link in comments].
我怀疑选项3将是最简单的方法,但是检查是否有人遇到类似问题并设法在Azure的npm start
中直接运行babel-node
.
I suspect option 3 will be easiest but checking if anyone has come across a similar issue and managed to run babel-node
directly in npm start
on Azure.
推荐答案
根据您的问题,请在Azure Web Apps上将start
npm脚本修改为node ./node_modules/babel-cli/bin/babel-node.js index.js
.
According your issue, please modify your start
npm script to node ./node_modules/babel-cli/bin/babel-node.js index.js
on Azure Web Apps.
这是测试package.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
中指定,请参考
Meanwhile if you need a higher Node.js version, you can specify in package.json
, refer to https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/ for more.
这篇关于Azure Node.js Web应用程序的自定义启动命令(ES2015/babel)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!