带有 Babel 6 的 Azure 上 Node.js 应用程序的自定义启动命令 [英] Custom startup command for Node.js app on Azure with Babel 6

查看:23
本文介绍了带有 Babel 6 的 Azure 上 Node.js 应用程序的自定义启动命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与 这个问题 并没有真正解决,因为最初的提问者放弃了这条路线.我正在尝试使用 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,node 版本是 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 Apps 上运行 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 上的 example 存储库,它利用了 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脚本.

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

这篇关于带有 Babel 6 的 Azure 上 Node.js 应用程序的自定义启动命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆