0
votes

I am trying to deploy an example app on the azure portal and am encountering some difficulties.

At first I'm just testing, so I've created an angular app with just ng new poc-pwa-angular-v2. After that I went up to a Bitbucket repository.

In Azure I created a web application and in the deployment options I connected on bitbucket and set my master branch.

I tried to generate the scripts with kudu (deploy.cmd and .deployment), but I got an error on the first deploy.

Can anyone give a tip?

Look at my log.

Command: deploy.cmd
Handling node.js deployment.
Creating app_offline.htm
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'package.json'
Deleting app_offline.htm
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".
Looking for app.js/server.js under site root.
Missing server.js/app.js files, web.config is not generated
The package.json file does not specify node.js engine version constraints.
The node.js application will run with the default node.js version 10.6.0.
Selected npm version 6.1.0

> [email protected] postinstall D:\home\site\wwwroot
> npm run build


> [email protected] build D:\home\site\wwwroot
> ng build

'ng' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `ng build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_35_989Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `npm run build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
Failed exitCode=1, command="D:\Program Files (x86)\nodejs\10.6.0\node.exe" "D:\Program Files (x86)\npm\6.1.0\node_modules\npm\bin\npm-cli.js" install --production
npm ERR!     D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_36_053Z-debug.log
An error has occurred during web site deployment.
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".\r\nMissing server.js/app.js files, web.config is not generated\r\n'ng' is not recognized as an internal or external command,\r\noperable program or batch file.\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! [email protected] build: `ng build`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the [email protected] build script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR!     D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_35_989Z-debug.log\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! [email protected] postinstall: `npm run build`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the [email protected] postinstall script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR!     D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_36_053Z-debug.log\r\nD:\Program Files (x86)\SiteExtensions\Kudu\78.11022.3613\bin\Scripts\starter.cmd deploy.cmd
2
If you're copying the built files within the dist directory (which is a good thing), you don't need the ones in the src directory, nor do you need to call ng serve-- you just need to access the index.html from dist - user184994
@user184994 I updated my logo. I ran the "ng build prod" command to generate the files in the dist folder. This is my package.json ` { "name": "poc-pwa-angular-v2", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "postinstall": "npm run build" },` - lams
Yep, you're still calling ng serve looking at that error message. You don't need to call ng serve-- that's only for local development. You just need to serve the files within the dist directory - user184994
@user184994 Thanks for the clarification, in this case I removed from the package.json the "script" block and went up again and it worked - lams

2 Answers

2
votes

The issue is that on Azure Angular cli is not installed. You will need to do ng build locally(or as part of your build and release pipe line. You can also use Azure DevOps builds for that where you have 240 build minutes for free) and upload it to (just options):

  1. Azure App service.
  2. Upload it to blob storage and use Azure functions proxy to serve your files.
  3. If you need server side rendering then you will need to upload it as an NodeJs app or part of .net app
0
votes

Thanks for the time of yours, in this case I removed the package.json script block and went up again and it worked.

...
"version": "0.0.0",
  "scripts": {
  },
...