[英]ASP.NET Core 2 Angular 5 project template doesn't publish
我正在使用此項目模板 ,到目前為止,一切都很完美。 使用項目啟動的dotnet run
命令,我可以更改客戶端文件並重新加載。 現在,我快要完成了,我嘗試使用dotnet publish --configuration=Release
,並引發以下錯誤:
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in 'C:\Users\********\***\***\********\ClientApp\src'
resolve './app/app.module.ngfactory' in 'C:\Users\********\***\***\********\ClientApp\src'
using description file: C:\Users\********\***\***\********\ClientApp\package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Users\********\***\***\********\ClientApp\package.json (relative path: ./src)
using description file: C:\Users\********\***\***\********\ClientApp\package.json (relative path: ./src/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory.js doesn't exist
as directory
C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory doesn't exist
[C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory]
[C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory.ts]
[C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory.js]
[C:\Users\********\***\***\********\ClientApp\src\app\app.module.ngfactory]
@ ./src/main.ts 3:0-66
@ multi ./src/main.ts
如果我切換到./ClientApp文件夾並嘗試ng build --extract-css --prod
則會得到相同的結果,但是我不知道是什么原因引起的? 此錯誤消息對我沒有任何意義。
./ClientApp/package.json
"name": "*******",
"version": "0.9.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
"build:ssr": "npm run build -- --app=ssr --output-hashing=media",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/schematics": "0.0.40",
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.9",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"file-saver": "^1.3.3",
"ng2-dragula": "^1.5.0",
"ng2-file-upload": "^1.3.0",
"ngx-bootstrap": "^2.0.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.6.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
更新#1:
它在禁用aot的情況下進行構建: ng build --extract-css --prod --aot false
在禁用AOT的情況下進行構建。 添加的@tomichel 鏈接描述了一些可能的原因,但對我來說,是一些較舊的客戶端庫與AOT不兼容。 因此,現在禁用AOT可以解決此問題:
ng build --extract-css --prod --aot false
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.