Azure上使用Babel 6的Node.js应用程序的自定义启动命令 [英] Custom startup command for Node.js app on Azure with Babel 6
问题描述
我遇到与这个问题由于原始提问者放弃了这条路线而没有真正解决。我正在尝试使用Babel6在Azure上运行节点应用程序。我正在使用的 package.json
文件中包含以下内容:
I'm having the same issue as this question which wasn't really resolved as the original questioner abandoned this route. I'm trying to run a node app on Azure using Babel6. The package.json
file I'm using has the following in it:
"scripts": {
"start": "node ./node_modules/babel-cli/bin/babel-node.js server.js"
}
我已使用Azure控制台检查并安装了 babel-cli
节点模块并且 server.js
文件位于 wwwroot
中。尽管如此,当我提交Azure时,我得到以下内容:
I've checked using the Azure console and the babel-cli
node module is installed and the server.js
file is in wwwroot
. Despite this I get the following when I commit to Azure:
remote: Start script "./node_modules/babel-cli/bin/babel-node.js
server.js" from package.json is not found.
在Azure上运行的npm版本是3.10.3,节点版本是6.6.0。任何人都可以建议如何启动和运行。任何帮助非常感谢!
The npm version running on Azure is 3.10.3, node version is 6.6.0. Can anyone advise on how to get this up and running. Any help much appreciated!
推荐答案
似乎在Web应用程序中运行ES2015中的node.js应用程序。我们需要将它们编译为ES5版本,您可以利用自定义部署脚本实现这一目标。
It seems that to run node.js applications in ES2015 on Web Apps. We need to compile them to ES5 version, you can leverage Custom Deployment Script to achieve this.
这是示例在GitHub上的repos,它利用 gulp
和自定义部署脚本,通过Azure部署任务将node.js从ES6编译到ES5。
Here is example repos on GitHub, which leverages gulp
and custom deployment script to compile the node.js from ES6 to ES5 via the Azure deployment task.
特别是,此示例在 package.json
中为部署任务调用定义了几个脚本:
Specially, this example defines several scripts in package.json
for the deployment task calling:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "gulp nodemon",
"build": "gulp build"
},
在 KuduSync
deploy.cmd 中的npm脚本> task将部署文件夹移动到生产文件夹。
And manually call the npm scripts in deploy.cmd
before KuduSync
task move the deployment folder to production folder.
:Deployment
echo Handling node.js deployment.
:: 0. Select node version for build
call :SelectNodeVersion
:: 1. Install build dependencies
pushd "%DEPLOYMENT_SOURCE%"
call :ExecuteCmd !NPM_CMD! install --production
IF !ERRORLEVEL! NEQ 0 goto error
popd
:: 2. Run build command
pushd "%DEPLOYMENT_SOURCE%"
call :ExecuteCmd !NPM_CMD! run-script build
IF !ERRORLEVEL! NEQ 0 goto error
popd
这篇关于Azure上使用Babel 6的Node.js应用程序的自定义启动命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!