Error app/main.js 404 Not Found on Azure

非 Y 不嫁゛ 提交于 2019-12-25 04:26:05

问题


My angular2 application deployment is clean but when i try to access the url to the same i get the error : app/main.js 404 (Not Found). Also I see no javascript files being created on the go on KUDU. The typescripts files are not compiled as I could make of it. Should i build ts to js on local and then push the js files also on git? Could anyone please suggest what is required to do so.

PS: My web.config file in root directory is as follows:

<configuration>
    <system.web>
        <customErrors mode="Off" />
        <compilation debug="true" targetFramework="4.5">
        </compilation>
    </system.web>
</configuration>

My Package.json is :

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "engines": {
    "node": "6.1.0",
    "npm": "3.8.6"
  }, 
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "docker-build": "docker build -t ng2-quickstart .",
    "docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
    "pree2e": "npm run webdriver:update",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "node_modules\\.bin\\lite-server",
    "postinstall": "typings install && tsc",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "node_modules\\.bin\\tsc",
    "concurrently": "node_modules\\.bin\\concurrently",
    "tsc:w": "node_modules\\.bin\\tsc -w",
    "typings": "node_modules\\.bin\\typings",
    "webdriver:update": "webdriver-manager update"
  },
  "keywords": [],
  "author": "",
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/angular/angular.io/blob/master/LICENSE"
    }
  ],
  "dependencies": {
    "@angular/common": "~2.1.0",
    "@angular/compiler": "~2.1.0",
    "@angular/core": "~2.1.0",
    "@angular/forms": "~2.1.0",
    "@angular/http": "~2.1.0",
    "@angular/platform-browser": "~2.1.0",
    "@angular/platform-browser-dynamic": "~2.1.0",
    "@angular/router": "~3.1.0",
    "@angular/upgrade": "~2.1.0",

    "angular-in-memory-web-api": "~0.1.5",
    "bootstrap": "^3.3.7",
    "ng2-bootstrap": "^1.1.14",
    "moment": "^2.15.2",
    "firebase": "^3.5.2",
    "angularfire2": "^2.0.0-beta.5",
    "systemjs": "0.19.39",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.25",
    "concurrently": "^3.0.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.3",
    "typings": "^1.4.0"
  },
  "devDependencies": {
    "concurrently": "^3.0.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.3",
    "typings": "^1.4.0",

    "canonical-path": "0.0.2",
    "http-server": "^0.9.0",
    "tslint": "^3.15.1",
    "lodash": "^4.16.2",
    "jasmine-core": "~2.5.2",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-htmlfile-reporter": "^0.3.4",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^3.3.0",
    "rimraf": "^2.5.4"
  },
  "repository": {}
}

If I modify the postinstall command to this I get the ts files compiled to js on kudu but get deployment errors.:

"postinstall": "typings install && tsc"

I get below error:


回答1:


By default, Azure Web Apps’ deployment task uses npm install --production command to install the dependencies in your package.json, which will skips all the dependencies configured in devDependencies section.

So first, you can move all the dependencies in devDependencies section to dependencies section.

As your ts files can be compiled into javascript after the node.js modules installation finished during the deployment task, you could use "postinstall": "typings install && tsc" instead of "postinstall": "typings install && tsc" to achieve this.

Any further concern, please feel free to let me know.



来源:https://stackoverflow.com/questions/40231071/error-app-main-js-404-not-found-on-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!