在azure上找不到错误app/main.js 404

m0rkklqb  于 2021-06-20  发布在  Kudu
关注(0)|答案(1)|浏览(421)

我的angular2应用程序部署是干净的,但是当我尝试访问相同的url时,我得到了错误:app/main.js404(找不到)。我也没有看到任何javascript文件正在创建的去kudu。typescripts文件没有像我所能理解的那样编译。我应该在本地构建ts到js,然后在git上推送js文件吗?请任何人提出这样做的要求。

ps:根目录中的web.config文件如下所示:

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

我的package.json是:

{
  "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": {}
}

如果我将postinstall命令修改为这个命令,我会在kudu上将ts文件编译为js,但会出现部署错误:

"postinstall": "typings install && tsc"

我得到以下错误:

iyfamqjs

iyfamqjs1#

默认情况下,azure web应用程序的部署任务使用 npm install --production 命令来安装 package.json ,这将跳过中配置的所有依赖项 devDependencies 部分。
因此,首先,可以将所有依赖项移入 devDependencies 节至 dependencies 部分。
由于可以在部署任务期间完成node.js模块安装后将ts文件编译为javascript,因此可以使用 "postinstall": "typings install && tsc" 而不是 "postinstall": "typings install && tsc" 为了达到这个目的。
如有任何问题,请随时通知我。

相关问题