我遇到与this question相同的问题,因为原始提问者放弃了这条路线,但这个问题并没有真正得到解决。我正在尝试使用Babel6在Azure上运行节点应用程序。我正在使用的package.json
文件中包含以下内容:
"scripts": {
"start": "node ./node_modules/babel-cli/bin/babel-node.js server.js"
}
我已使用Azure控制台检查并安装了babel-cli
节点模块,server.js
文件位于wwwroot
。尽管如此,当我提交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。任何人都可以建议如何启动和运行。任何帮助非常感谢!
答案 0 :(得分:1)
似乎要在Web Apps上运行ES2015中的node.js应用程序。我们需要将它们编译为ES5版本,您可以利用Custom Deployment Script来实现这一目标。
以下是GitHub上的example repos,它利用gulp
和自定义部署脚本通过Azure部署任务将node.js从ES6编译到ES5。
特别是,此示例在package.json
中为部署任务调用定义了几个脚本:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "gulp nodemon",
"build": "gulp build"
},
在deploy.cmd
任务将部署文件夹移动到生产文件夹之前,手动调用KuduSync
中的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