找不到模块:错误:无法解析' ./ app / app.module.ngfactory'

时间:2017-12-18 16:00:08

标签: typescript webpack angular5 2sxc

我无法使用AOT(ng build --prod)编译我的Angular 5应用程序。有什么问题?

  

找不到模块:错误:无法解析' ./ app / app.module.ngfactory'在   ' C:\项目\ APP-DNN-SXC - 角-dev的\ SRC' @ ./src/main.ts 3:0-66 @   multi ./src/main.ts

我们正在开发此应用程序以使用Angular 5测试我们的dnn-sxc-angular npm项目。一旦从ContentManagerModule导入@2sic.com/dnn-sxc-angular,AOT构建就会失败。

我跑了node_modules/.bin/ngc.cmd但没有出现错误。有没有办法调试构建过程或获取人类可读的错误消息?

破解的演示应用: https://github.com/2sic/app-dnn-sxc-angular-dev

dnn-sxc-angular(与Angular 4合作): https://github.com/2sic/dnn-sxc-angular

项目结构 enter image description here

我的环境:

  • Windows 10
  • npm:5.6.0
  • node:8.9.3
  • angular cli(本地和全球):1.6.1

webpack --bail的完整输出:

  

C:\ Projects \ app-dnn-sxc-angular-dev> webpack --bail 11%building   modules 9/9 modules 0 activeModuleNotFoundError:找不到模块:   错误:无法解析' ./ app / app.module.ngfactory'在   ' C:\项目\ APP-DNN-SXC - 角-dev的\ SRC'       at factoryCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ lib \ Compilation.js:276:40)       在工厂(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ lib \ NormalModuleFactory.js:235:20)       在解析器(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ lib \ NormalModuleFactory.js:60:20)       在asyncLib.parallel(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ lib \ NormalModuleFactory.js:127:20)       在C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ async \ dist \ async.js:3874:9       在C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ async \ dist \ async.js:473:16       at iteratorCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ async \ dist \ async.js:1048:13)       在C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ async \ dist \ async.js:958:16       在C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ async \ dist \ async.js:3871:13       at resolvers.normal.resolve(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ lib \ NormalModuleFactory.js:119:22)       在onError(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:65:10)       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       at runAfter(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:158:4)       在innerCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:146:3)       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       在下一个(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ tapable \ lib \ Tapable.js:252:11)       在C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ UnsafeCachePlugin.js:40:4       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       at runAfter(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:158:4)       在innerCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:146:3)       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       在下一个(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ tapable \ lib \ Tapable.js:252:11)       在innerCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:144:11)       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       在下一个(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ tapable \ lib \ Tapable.js:249:35)       at resolver.doResolve.createInnerCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ DescriptionFilePlugin.js:44:6)       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       at afterInnerCallback(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ Resolver.js:168:10)       在loggingCallbackWrapper(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ webpack \ node_modules \ enhanced-resolve \ lib \ createInnerCallback.js:31:19)       在下一个(C:\ Projects \ app-dnn-sxc-angular-dev \ node_modules \ tapable \ lib \ Tapable.js:252:11)   解决' ./ app / app.module.ngfactory'在   ' C:\项目\ APP-DNN-SXC - 角-dev的\ SRC'使用描述文件:   C:\ Projects \ app-dnn-sxc-angular-dev \ package.json(相对路径:   ./src)       Field'浏览器'使用描述文件后,不包含有效的别名配置:   C:\ Projects \ app-dnn-sxc-angular-dev \ package.json(相对路径:   ./src)       使用描述文件:C:\ Projects \ app-dnn-sxc-angular-dev \ package.json(相对路径:   ./src/app/app.module.ngfactory)         没有延期           Field'浏览器'不包含有效的别名配置           C:\项目\ APP-DNN-SXC - 角-dev的\ SRC \应用\ app.module.ngfactory   不存在         .TS           Field'浏览器'不包含有效的别名配置           C:\项目\ APP-DNN-SXC - 角-dev的\ SRC \应用\ app.module.ngfactory.ts   不存在         .js文件           Field'浏览器'不包含有效的别名配置           C:\项目\ APP-DNN-SXC - 角-dev的\ SRC \应用\ app.module.ngfactory.js   不存在         作为目录           C:\项目\ APP-DNN-SXC - 角-dev的\ SRC \应用\ app.module.ngfactory   不存在

     

C:\项目\ APP-DNN-SXC - 角-dev的>

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

ng build --prod --aot