ng build --prod build failed after running npm install in new folder

大兔子大兔子 提交于 2019-12-06 05:29:49

问题


Here is the error getting in prod build

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/var/www/project/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

Getting error because new versions of packages being installed after running npm install. Cannot share packages version differences because the list is too lengthy. Its working with aot false but don't want to build with aot false. Not able to find out which package is responsible for this.


回答1:


Try

npm i enhanced-resolve@3.3.0

or add it to your shrinkwrap.json or package-lock.json or yarn.lock or update angular-cli as said Filipe Silva

We've released 1.2.4/1.3.0-rc.1 to fix this issue

I also had issue with enhanced-resolve: angular-cli didn't respect my --environment flag

See also this thread

  • https://github.com/angular/angular-cli/issues/7113



回答2:


  1. npm clean cache
  2. Delete node_modules
  3. Add "enhanced-resolve": "3.3.0" in your package.json
  4. run npm install
  5. rebuild !

I solved it with this thread

https://github.com/angular/angular-cli/issues/7113



来源:https://stackoverflow.com/questions/45283334/ng-build-prod-build-failed-after-running-npm-install-in-new-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!