[英]Custom startup command for Node.js app on Azure with Babel 6
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.
我正在尝试使用Babel6在Azure上运行节点应用程序。 The
package.json
file I'm using has the following in it: 我正在使用的
package.json
文件中包含以下内容:
"scripts": {
"start": "node ./node_modules/babel-cli/bin/babel-node.js server.js"
}
I've checked using the Azure console and the babel-cli
node module is installed and the server.js
file is in wwwroot
. 我已经使用Azure控制台进行了检查,并且安装了
babel-cli
节点模块,并且server.js
文件位于wwwroot
。 Despite this I get the following when I commit to Azure: 尽管如此,当我承诺使用Azure时,仍然得到以下信息:
remote: Start script "./node_modules/babel-cli/bin/babel-node.js
server.js" from package.json is not found.
The npm version running on Azure is 3.10.3, node version is 6.6.0. 在Azure上运行的npm版本是3.10.3,节点版本是6.6.0。 Can anyone advise on how to get this up and running.
任何人都可以建议如何启动和运行它。 Any help much appreciated!
任何帮助,不胜感激!
It seems that to run node.js applications in ES2015 on Web Apps. 似乎要在Web Apps的ES2015中运行node.js应用程序。 We need to compile them to ES5 version, you can leverage Custom Deployment Script to achieve this.
我们需要将它们编译为ES5版本,您可以利用Custom Deployment Script来实现。
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. 这是GitHub上的示例存储库,该存储库利用
gulp
和自定义部署脚本通过Azure部署任务将node.js从ES6编译到ES5。
Specially, this example defines several scripts in package.json
for the deployment task calling: 特别地,此示例在
package.json
为部署任务调用定义了几个脚本:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "gulp nodemon",
"build": "gulp build"
},
And manually call the npm scripts in deploy.cmd
before KuduSync
task move the deployment folder to production folder. 并在
KuduSync
任务将部署文件夹移动到生产文件夹之前,手动调用deploy.cmd
的npm脚本。
: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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.