无法发布asp.net核心/角度项目。无法解析app.server.module.ngfactory?

时间:2017-12-20 16:03:30

标签: asp.net angular visual-studio webpack .net-core

使用VS2017角度模板并创建了一个应用程序。然后试图发布它。我也升级到Angular 5.

关于ngfactory的这个错误的任何想法都是关于???

./ClientApp/boot.server.ts中的错误 找不到模块:错误:无法解析'./../$$_gendir/ClientApp/app/app.server.module.ngfacto ry'in'C:\ Users \ Matt_Herb \ downloads \ ibewsurveytemp \ ibewsurveytemp \ ClientApp'[C:\ Users \ Matt_Her b \下载\ ibewsurveytemp \ ibewsurveytemp \ IbewSurveyTemp.csproj]        @ ./ClientApp/boot.server.ts 8:0-94

执行错误:错误错误:请更新@ angular / cli。 Angular 5+至少需要Angular CLI 1.5 + [C:\ Users \ Matt_Herb \ downloads \ ibewsurveytemp \ ibewsurveytemp \ IbewSurveyTemp.csproj]           at throwNotSupportedError(C:\ Users \ Matt_Herb \ downloads \ ibewsurveytemp \ ibewsurveytemp \ 包\编译-CLI \ SRC \ ngtools_api.ts:132:9)           在Function.NgTools_InternalApi_NG_2.codeGen(C:\ Users \ Matt_Herb \ downloads \ ibewsurveyt) EMP \ ibewsurveytemp \包\编译-CLI \ SRC \ ngtools_api.ts:80:11)           在_donePromise.Promise.resolve.then(C:\ Users \ Matt_Herb \ downloads \ ibewsurveytemp \ ibew surveytemp \ node_modules \ @ngtools \的WebPack的\ src \ plugin.js:430:58)           在           at process._tickCallback(internal / process / next_tick.js:188:7)           在Function.Module.runMain(module.js:684:11)           在启动时(bootstrap_node.js:191:16)           在bootstrap_node.js:613:3 C:\ Users \ Matt_Herb \ downloads \ ibewsurveytemp \ ibewsurveytemp \ IbewSurveyTemp.csproj(48,5):错误MS B3073:命令“node node_modules / webpack / bin / webpack.js --env.prod”退出,代码为2。

2 个答案:

答案 0 :(得分:2)

好的......它看起来像你的依赖关系等等问题..这个:

1 - update your angular cli with : npm install -g @angular/cli

2 - delete your node_modules in your project (maybe with rimraf)

3 - delete your package-lock.json file (if you've one)

4 - try to run in a different folder ng new testProject --skip-install=true (so it generate WITHOUT install packages a new angular project ..)

5 - go in that project and copy the @angular and other dependencies in package.json file and paste in your project .. save the updated package.json
file of your project

6 - run a npm install --f in your project

7 - try to run a ng serve .. and check if the project load

希望它可以帮到你

答案 1 :(得分:1)

Angular 5需要使用不同的编译器插件到Angular 4,

尝试使用webpack.config.js中的'AngularCompilerPlugin'搜索/替换'AotPlugin'

请参阅:https://www.npmjs.com/package/@ngtools/webpack

我遇到的下一个问题是测试文件在发布时无法编译, webpack规则和AngularCompilerPlugin构造函数上的'exclude'属性似乎不起作用,所以我在tsconfig.json中将它们排除在外:

  "exclude": [ "bin", "node_modules", "**/*.spec.ts" ],