evertonrobertoauler / cli-universal-demo

80 stars 18 forks source link

Can't resolve './$$_gendir/ #30

Closed webkingashu closed 7 years ago

webkingashu commented 7 years ago

Encountered error whille running npm run start

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/neo/workspace/cli-universal-demo/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/neo/workspace/cli-universal-demo/src/$$_gendir/app/home/home.module.ngfactory.ts' in '/home/neo/workspace/cli-universal-demo/src/$$_gendir'
 @ ./src/$$_gendir async
 @ ./~/@angular/core/@angular/core.es5.js
 @ ./src/main.ts
 @ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/neo/workspace/cli-universal-demo/src/$$_gendir/app/about/about.module.ngfactory.ts' in '/home/neo/workspace/cli-universal-demo/src/$$_gendir'
 @ ./src/$$_gendir async
 @ ./~/@angular/core/@angular/core.es5.js
 @ ./src/main.ts
 @ multi ./src/main.ts

Tried angular universal official doc as well as this repo There is the issue of "import token" and here is this issue

adamj88 commented 7 years ago

Receiving the same error after following this post: https://medium.com/@evertonrobertoauler/angular-4-universal-app-with-angular-cli-db8b53bba07d

murilobd commented 7 years ago

Yeap! The same error as here!

If i run "ng build" works fine, but when run "ng build --prod" it happens this error

suau commented 7 years ago

FYI, add this to your package.json dependencies: "enhanced-resolve": "3.3.0", and delete the node_modules folder, after that run npm install again.

ahaw commented 7 years ago

@suau thanks for reply but it didn't help in my case, I tried enhanced-resolve 3.3.0 (and 3.4.1) with and without deleting node_modules

suau commented 7 years ago

@ahaw try updating to "@angular/cli": "1.2.4"

after npm install go to node_modules/enhanced-resolve/package.json and make sure it's version 3.3.0

ahaw commented 7 years ago

@suau Thanks! It worked. The problem was no matter how I modified packages.json enchanced-resolve in version 3.4.1 was installed. I needed to delete it and manually type

npm install enhanced-resolve@3.3.0

evertonrobertoauler commented 7 years ago

This was fixed by the @angular/cli or the webpack folks, just update it by running npm install -g @angular/cli, remove the node_module in the project and install the dependencies again and everything will work again.