我的angular2应用程序部署是干净的,但是当我尝试访问相同的URL时,我得到错误:app / main.js 404(Not Found)。此外,我发现在KUDU上没有创建任何javascript文件。打字稿文件不是按照我的方式编译的。我应该在本地构建ts到js然后在git上推送js文件吗?任何人都可以建议做什么。
<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"
答案 0 :(得分:1)
默认情况下,Azure Web Apps的部署任务使用npm install --production
命令在package.json
中安装依赖项,这将跳过devDependencies
部分中配置的所有依赖项。
首先,您可以将devDependencies
部分中的所有依赖项移至dependencies
部分。
在部署任务期间完成node.js模块安装后,可以将ts文件编译为javascript,
您可以使用"postinstall": "typings install && tsc"
代替"postinstall": "typings install && tsc"
来实现此目标。
如有任何疑问,请随时告诉我。