我使用this project template,到目前为止一切都很完美。使用项目启动的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:
它是在禁用时构建的:ng build --extract-css --prod --aot false
答案 0 :(得分:0)
正在禁用AOT的情况下进行构建。添加的link @tomichel描述了一些可能的原因,但对我来说,是一些较旧的客户端库与AOT不兼容。因此,现在禁用AOT即可解决此问题:
y