在 Azure 中部署 Angular4 通用应用程序无效启动命令 [英] Deploy Angular4 Universal app in Azure invalid start-up command

查看:24
本文介绍了在 Azure 中部署 Angular4 通用应用程序无效启动命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 这些步骤

基本上这意味着它是一个 Angular 4 应用程序,能够在 NodeJs 环境中的服务器端呈现.

Basically it means that it's an Angular 4 application capable of being rendered in server side within a NodeJs environment.

现在我想使用 Git 和命令行将此应用程序部署到我的 Azure 应用程序服务,因此我遵循了 这些步骤.基本上:

Now I want to deploy this application to my Azure app services using Git and a command line so I followed these steps. Basically:

  1. 为 Windows 安装了 Azure-Cli 2.0
  2. 打开命令行(cmd)
  3. 运行 az login,它会要求打开一个 url 并输入一个代码,以便我们可以使用它进行身份验证
  4. 使用 az webapp 部署用户集 --user-name 配置部署用户--password
  5. 使用 az group create --name myResourceGroup --location westeurope 创建资源组
  6. 使用 az appservice plan create --name myServicePlan --resource-group myResourceGroup --sku B1 创建基本服务计划
  7. 使用 az webapp create --name myApp --resource-group myResourceGroup --plan myServicePlan 创建 Web 应用程序
  8. 使用带有 az webapp deployment source config-local-git --name myUSer --resource-group myResourceGroup --query url --output tsv 的 GIT 配置部署并返回 https://myUser@myApp.scm.azurewebsites.net/myApp.git
  9. 使用 git remote add azure https://myUser@myApp.scm.azurewebsites.net/myApp.git
  10. 将 Azure 远程添加到本地 git 存储库
  11. 使用 git push azure master 推送到 Azure 远程部署应用程序,它会提示输入在第 4 步中设置的用户名和密码.
  1. I installed Azure-Cli 2.0 for Windows
  2. Open command line (cmd)
  3. Run az login, it will ask to open a url and enter a code so that we can authenticate with it
  4. Configure a deployment user with az webapp deployment user set --user-name <myUser> --password <myPassword>
  5. Create resource group with az group create --name myResourceGroup --location westeurope
  6. Create basic service plan with az appservice plan create --name myServicePlan --resource-group myResourceGroup --sku B1
  7. Create web application with az webapp create --name myApp --resource-group myResourceGroup --plan myServicePlan
  8. Configure deployment with GIT with az webapp deployment source config-local-git --name myUSer --resource-group myResourceGroup --query url --output tsv and it returns https://myUser@myApp.scm.azurewebsites.net/myApp.git
  9. Add an Azure remote to local git repository with git remote add azure https://myUser@myApp.scm.azurewebsites.net/myApp.git
  10. Push to Azure remote to deploy app with git push azure master, it will prompt for the username and password set on step 4.

我收到一些错误消息,说某些依赖项在 npm 中不可用.我注意到正在使用的 Azure nodeJs 很旧,因此为了强制我的 Azure 应用服务使用我在本地使用的相同节点版本(node --versionv8.0.0> 我在我的 package.json 中添加了一个 engines 部分,如下所示:

I got some errors saying that some dependencies were not available in npm. I noticed that the Azure nodeJs being used was old, so to enforce my Azure app services to use the same node version I am using locally (node --version is v8.0.0 I added an engines section in my package.json like this:

"engines": {
    "node": "8.0.0"
  }

所以现在我的package.json如下:

{
  "name": "myApp",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "prestart": "ng build --prod && ngc",
    "start": "ts-node src/server.ts"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.1.3",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/platform-server": "^4.1.3",
    "@angular/router": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  },
  "engines": {
    "node": "8.0.0"
  }
}

我遇到的问题是,当我运行 git push azure master 以在 Azure 中部署时,我在 package.json 中得到一个 无效的启动命令 ts-node src/server.ts 以便应用程序在 Azure 中,但无法部署且无法运行.这是我的输出:

The problem I have is that when I run git push azure master to deploy in Azure I get an invalid start-up command ts-node src/server.ts in package.json so that the application is in Azure but it fails to be deployed and doesn't run. This is my output:

$ git push azure master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 344 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id 'd7229584fc'.
remote: Generating deployment script.
remote: Running deployment command...
remote: Handling node.js deployment.
remote: KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
remote: Copying file: 'package.json'
remote: Looking for app.js/server.js under site root.
remote: Node.js versions available on the platform are: 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.8.27, 0.8.28, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28, 0.10.29, 0.10.31, 0.10.32, 0.10.40, 0.12.0, 0.12.2, 0.12.3, 0.12.6, 4.0.0, 4.1.0, 4.1.2, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.3.0, 4.3.2, 4.4.0, 4.4.1, 4.4.6, 4.4.7, 4.5.0, 4.6.0, 4.6.1, 5.0.0, 5.1.1, 5.3.0, 5.4.0, 5.5.0, 5.6.0, 5.7.0, 5.7.1, 5.8.0, 5.9.1, 6.0.0, 6.1.0, 6.2.2, 6.3.0, 6.5.0, 6.6.0, 6.7.0, 6.9.0, 6.9.1, 6.9.2, 6.9.4, 6.9.5, 6.10.0, 7.0.0, 7.1.0, 7.2.0, 7.3.0, 7.4.0, 7.5.0, 7.6.0, 7.7.4, 7.10.0, 8.0.0.
remote: Selected node.js version 8.0.0. Use package.json file to choose a different version.
remote: Selected npm version 5.0.0
remote: Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml
remote: Invalid start-up command "ts-node src/server.ts" in package.json. Please use the format "node <script relative path>".
remote: Missing server.js/app.js files, web.config is not generated
remote: ......
remote: npm WARN lifecycle The node binary used for scripts is D:\Program Files (x86)\nodejs\0.10.28\node.exe but npm is using D:\Program Files (x86)\nodejs\8.0.0\node.exe itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
remote: ........................................................
remote: added 17 packages in 73.406s
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
To https://myApp.scm.azurewebsites.net/myApp.git
   d497e43..d722958  master -> master

这是我第一次尝试在 nodeJs 中部署一些东西,关于发布一个 Angular 应用程序用于生产还有很多我不知道的事情.当我运行 npm start 时,我错过了什么让它在本地工作?

It's the first time I attempt to deploy something in nodeJs and there are plenty of things I don't know yet about releasing for production an Angular app. What am I missing to make it work as it works locally when I run npm start?

推荐答案

您似乎收到了格式错误的启动命令错误

It looks like you're getting an error for a malformed start command

remote: Invalid start-up command "ts-node src/server.ts" in package.json. Please use the format "node <script relative path>".

文档示例node 而不是 ts-node

这篇关于在 Azure 中部署 Angular4 通用应用程序无效启动命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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