projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.12k stars 654 forks source link

Trouble configuring Kudu with new angular-cli project with devDependencies #2147

Closed ghost closed 4 months ago

ghost commented 7 years ago

Before I deploy to Kudu I run this command to create .deployment and deploy.sh.
azure site deploymentscript --node

But then the problem is getting Kudu to install the devDependencies, specifically ng from angular-cli. Here is packages.json from angular-cli, with an addition of "engines" line at the end for Kudu. The problem is "start": "ng serve", or what it should really be for a Kudu deployment ng build, but it can't find ng at all.

{
  "name": "astarapp",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "core-js": "^2.4.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.15",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.5",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  },
  "engines":{"node": "6.6.0"}
}

Error is:

Start script "ng serve" from package.json is not found.

What am I missing?

davidebbo commented 7 years ago

Could you share a small repo that demonstrates this error? Thanks!

ghost commented 7 years ago

https://github.com/jmb-mage/KuduRepo there is the repo.

I think the problem is the Kudu npm install runs in prod mode, and therefore does not install the devDependencies? Is there some way to change deploy.sh so that it install the devDependencies before Kudu runs npm install?

davidebbo commented 7 years ago

Looks like your repo is using its own custom deployment script (here). So you should be able to change it to do whatever you want.

ghost commented 7 years ago

How would I change the deploy.sh script to install the devDependencies from package.json before it runs npm install?

Sorry, my knowledge of Unix scripts and Kudu isn't enough.

doggy8088 commented 2 years ago

@davidebbo I'm trying to run npm insall, but it shows Error: Method Not Allowed. Please check the following log:

npm install
npm ERR! Error: Method Not Allowed
npm ERR!     at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)
npm run build -- --output-path "D:\home\site\repository\dist"
npm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12
npm ERR!     at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)
npm ERR!     at Object.oncomplete (fs.js:108:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "node" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd D:\home\site\repository
npm ERR! node -v v0.10.40

How to debug this Custom Deployment Script?

doggy8088 commented 2 years ago

It seems the Node.js version is really outdated.

Node.js Version
v0.10.40

I changed my appsettings using the following script fixed all my problem.

az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings WEBSITE_NODE_DEFAULT_VERSION="~16"

All the details here: https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script

davidebbo commented 2 years ago

@doggy8088 this is a very old issue, and I haven't been involved in Kudu is many years. I suggest opening a new issue to give it more attention.

doggy8088 commented 2 years ago

@davidebbo I already figured it out and solved. Thanks! :)

davidebbo commented 2 years ago

@doggy8088 Great!

jvano commented 4 months ago

Hi

If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure: https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

This way we can better track and assist you on this case

Thanks,

Joaquin Vano Azure App Service