Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' #7125

Closed
marciomsm opened this issue Jul 24, 2017 · 67 comments

Comments

@marciomsm
Copy link

I am getting ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' when I run ng build --prod, but if I run the command ng build --env=prod I get success.

Do we have any differences between these commands?

@ajalmaguer
Copy link

ajalmaguer commented Jul 24, 2017

Happens for me too. These are the versions of my project:

@angular/cli: 1.1.3
node: 6.11.0
os: darwin x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.3
@angular/compiler-cli: 4.2.4
@angular/language-service: 4.2.4

@marciomsm
Copy link
Author

I solved it setting the zone.js version to 0.8.14. I don't know if we have an issue on Angular-CLI or on zone.js.

@marius-oprea
Copy link

I did a successful ng build -prod a couple of hours ago, but now I get the same error without changing nothing to my project.

@bcravens
Copy link

@marius-oprea same thing just happened to me.

@mattrichard
Copy link

I'm getting the same error too. Updating zone.js did not work for me.

@jh-code
Copy link

jh-code commented Jul 24, 2017

Happening here as well. Very odd. Tried messing around with a lot of different versions of Angular, Angular CLI, Zone.js and others with no luck.

@ghost
Copy link

ghost commented Jul 24, 2017

Same here, tried updating zone.js and it did not work

@bcravens
Copy link

We eventually solved it by mass updating our node packages. Not sure which one solved the problem, wasn't zone.js though.

@ghost
Copy link

ghost commented Jul 24, 2017

@bcravens can you share your package.json?

@marius-oprea
Copy link

updating to @angular/cli 1.2.4 and the other packages to the latest version solved the issue for me.

@marciomsm
Copy link
Author

Change your package.json to zone.js: 0.8.14. Delete node_modules folder and run npm install again.

@ghost
Copy link

ghost commented Jul 24, 2017

Updating to @angular-cli: 1.2.4 fixed the issue for me.

@EricABC
Copy link

EricABC commented Jul 24, 2017

The patch rc.1 was released to address this, but others still indicate problems with rc.1 here: #7113. rc.1 fixed most of my apps, but for some sample projects I was using a tsconfig with 'include: []', relying on ng to pass my entrypoint to the compiler. When using AOT you will get this error even in rc.1 unless you include the entry points explicitly in tsconfig.

@joseph-mcallister
Copy link

joseph-mcallister commented Jul 24, 2017

None of the package updating worked for me but adding enhanced-resolve: 3.3.0 did. See #4551

@tianyuanzhonglu
Copy link

@angular/cli: 1.2.4 fix the problem

@philljones
Copy link

@angular/cli: 1.2.4 fixed the problem for me also - this on VSTS Hosted

@dkro
Copy link

dkro commented Jul 25, 2017

Getting the same error. CLI 1.2.4 and Zone 0.8.14 did not resolve the problem for me

@nille85
Copy link

nille85 commented Jul 25, 2017

Updating to @angular/cli: 1.2.4 also fixed the problem for me.

@PierreDuc
Copy link

If updating to 1.2.4 doesn't work for you. Make sure you remove your node_modules folder and your package-lock.json, and run npm install. And if even that doesn't work, install enhanced-resolve@3.3.0, to avoid installing the faulty package. And if that doesn't work, you should probably be looking at your own code :)

@atiris
Copy link

atiris commented Jul 25, 2017

Oh, @PierreDuc It would be nice, if you were right...
Everything updated/removed/installed, enhanced-resolve too... but after all of this I can run only ng build --aot without any Can't resolve 'src\$$_gendir\... bug. When I run ng commands with i18n option (it can be serve or build like ng serve --aot --locale sk --i18n-file locale/messages.sk.xmb --i18n-format xmb), I get Can't resolve './$$_gendir/app/app.module.ngfactory' ... and I'm pretty sure this is not due to my code :(

@flauc
Copy link

flauc commented Jul 25, 2017

@atiris Are you running on linux or windows? For some reason enhanced-resolve: 3.3.0 fixes it for my on windows, but not on linux. It's the same version of npm and node on both machines.

@PierreDuc
Copy link

@atiris Have you cleared your npm cache, and removed the angular-cli global package?

@atiris
Copy link

atiris commented Jul 25, 2017

@PierreDuc I do my complete procedure again just now:
cd <project>;
delete node_modules;
delete package-lock.json;
npm uninstall @angular/cli -g;
npm cache clean --force; (last time I run only npm cache verify)
npm install @angular/cli -g;
npm cache verify;
close / open console;
cd <project>;
npm install;
ng --version; (result: 1.2.4)
ng build --aot; (result: many errors type Can't resolve './$$_gendir/app/app.module.ngfactory')
checked package.json --> dependencies already contains "enhanced-resolve": "^3.3.0" but I run also next command
npm install enhanced-resolve@3.3.0 --save;
ng build --aot; (result: now everything is OK)
ng build --aot --locale sk --i18n-file locale/messages.sk.xmb --i18n-format xmb; (result: again the same error, but only one)

ERROR in Unsupported
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '<project>\src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

@flauc I run it on windows. My actual versions:

@angular/cli: 1.2.4, node: 8.1.3, npm: 5.3.0, os: win32 x64
@angular/animations, @angular/common, @angular/compiler, @angular/core, @angular/forms,
@angular/http, @angular/platform-browser, @angular/platform-browser-dynamic,
@angular/platform-server, @angular/router, @angular/upgrade, @angular/compiler-cli,
@angular/language-service: 4.3.1

@ankeshdave
Copy link

@filipesilva

I am also having the same problem,

Tried all solutions mentioned above

  • Using latest rc1
  • installed enhanced-resolve@3.3.0 still the same error.

The project is newly generated by the command

ng new my-prj --skip-install --skip-git -dir my-prj --style scss --routing

@x-c4mp3r
Copy link

x-c4mp3r commented Jul 25, 2017

@angular/cli: 1.2.4 fix the problem, but can't ng build --prod --aot, I got

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

The last fine build was done before angular 4.3

@frednomoon
Copy link

frednomoon commented Jul 25, 2017

Same issue here... only fix for me seems to be changing build script to use --env=prod instead of --prod. Updating @angular/cli and other packages didn't make a difference.

@filipesilva
Copy link
Contributor

filipesilva commented Jul 25, 2017

Heya, please see #7113 (comment) for this issue.

@nourson
Copy link

nourson commented Jul 25, 2017

Updating to @angular/cli@1.2.4 and zone.js@0.8.14
Then
remove node_modules directory
npm cache clear
npm install
fixed the issue with ng build --prod

@filipesilva
Copy link
Contributor

--env=prod and --prod are not the same thing. Please see #7113 (comment) for more information about it.

alex-arriaga added a commit to webtrainingmx/angular-project-manager-avanzado that referenced this issue Aug 3, 2017
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'

angular/angular-cli#7125
angular/angular-cli#7113
@SETI-At-Home
Copy link

SETI-At-Home commented Aug 9, 2017

Changing to "@angular/cli": "1.2.4" fixed the problem.

Make sure after changing from 1.0.0 ver to 1.2.4 to npm install before you ng build ...

@crsepulv
Copy link

My version is:

@angular/cli: 1.0.1
node: 6.7.0
os: win32 x64
@angular/common: 4.3.4
@angular/compiler: 4.3.4
@angular/core: 4.3.4
@angular/forms: 4.3.4
@angular/http: 4.3.4
@angular/platform-browser: 4.3.4
@angular/platform-browser-dynamic: 4.3.4
@angular/router: 4.3.4
@angular/cli: 1.0.1
@angular/compiler-cli: 4.3.4
and @mihau1 comment solve my problem : https://github.com/angular/angular-cli/issues/7125#issuecomment-317723824

@howard9104
Copy link

My original version is 1.2.1 and @angular/cli: 1.2.4 fixed the problem~

@kingsolo50
Copy link

kingsolo50 commented Aug 23, 2017

This worked for me
Step 1:
Delete the node_modules folder
Step 2:
Replace your package.json "devDependencies": with the following;

"@angular/cli": "^1.3.1",
"@angular/compiler-cli": "^4.0.0",  
"@angular/language-service": "^4.0.0",
"@types/jasmine": "2.5.45",
"@types/jquery": "^3.2.11",
"@types/node": "~6.0.60",
"codelyzer": "~3.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.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"

Step 3;
Run npm install

@dgroh
Copy link

dgroh commented Aug 28, 2017

same issue here, but using --env=prod solves the problem, anyways I would like to know what is causing this error

@dgroh
Copy link

dgroh commented Aug 28, 2017

I could fix the issue by running the following commands:

  1. npm install -g @angular/cli@latest
  2. npm install --save-dev @angular/cli@latest
  3. rimraf .\node_modules\
  4. ncu -u
  5. npm install
  6. npm cache clean

@yassinechabli
Copy link

Could someone told us about the source of this problem . because if i take my case , the command ng build --prod --aot was working fine . i don't change any thing on my project . and after a while . i have the same error ... updating the angular cli to the version 1.2.4 solve the problem for me . but still not getting what was the problem exactly ? . some help please .

@beauxjames-ZZ
Copy link

Note: Updating to angular-cli 1.2.4 solved the problem that started this thread for our instance of the installation.

Application development done both on Mac and Windows.
Deploying to Apache / Docker containers.

Of course, we also needed to do a fresh npm install.

@yassinechabli
Copy link

yassinechabli commented Sep 7, 2017

Thank you @beauxjames , but i found anoher problem when updating to the 1.2.6 . some module in my application are not working . so what you think should i do ? trying to solve this problem and keep the version 1.2.6 of angular or downgrade it to the old version and solve it with another way .

@achieverprince
Copy link

@yassinechabli
I was able to solve it in multiple project with CLI 1.2.6 +
Error you are getting now might be related to AOT, you can fix it if you follow the guidelines.
What error you are getting, may be some one can help.
Or search with that error messages separately and fix them.

@yassinechabli
Copy link

the problem was about a module (ngx-date-picker) that need to be updated also .
i don't know why , but i upgrade to the last version with some modification in my code and it works .
thank you @achieverprince .

@manishit56
Copy link

below command solved my issue
npm install enhanced-resolve@3.3.0

hsinlin added a commit to hsinlin/wages-by-gender that referenced this issue Sep 24, 2017
@justin48
Copy link

removing node_modules and running npm install worked for me.

@devssharma
Copy link

Sloved !!
I had this issue when i was trying the execute ng build -aot command.
problem slove for me when i changed the version of "@angular/cli": "1.2.0" to "@angular/cli": "1.3.0",

@imichelakos
Copy link

Sloved !!
I had this issue when i was trying the execute ng build -prod command.
Problem solved by updating the version of "@angular/cli": "1.0.0" to "@angular/cli": "1.3.0".

@scharlo
Copy link

scharlo commented Feb 1, 2018

None of the solutions worked for me, because the issue was about memory. Maybe the command below could work for those who couldn't find a solution. This solved the issue in my case.

node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod

@bharath005
Copy link

Could not resolve "./components/template/template.module" from "E:/vat_frontend/src/app/app.module.ts".

@tayyab786
Copy link

import React, { Component } from 'react';
import logo from './logo.svg';
import './image.css';
import Dropdown from 'react-dropdown';
import axios from 'axios';
import { AppRegistry, View, Image,Text, } from 'react-native';
// import 'react-dropdown/style.css';

class App extends Component {
state=
{
selectedFile:null
}
fileSelectHandler=event=>{
// console.log(event.target.files[0]);
this.setState({
selectedFile:event.target.files[0]
})
// fileUploadHandler=() =>
// {
// axios.post('')
//
// }
}

render() {

return (
    <div className="image-upload">
    <View>
    <Image
     source={require('D:\ofc\firstapp\src\bmw.jpg')}
   />
   </View>

    </div>


);

}
}

export default App;

m geeting error of
./src/practicee.js
Module not found: Can't resolve 'D:ofc irstappsrc�mw.jpg' in 'D:\ofc\firstapp\src'

can anyone help me

@tayyab786
Copy link

geeting error of
./src/practicee.js
Module not found: Can't resolve 'D:ofc irstappsrc�mw.jpg' in 'D:\ofc\firstapp\src'

can anyone help me

@tayyab786
Copy link

import React, { Component } from 'react';
import logo from './logo.svg';
import './image.css';
import Dropdown from 'react-dropdown';
import axios from 'axios';
import { AppRegistry, View, Image,Text, } from 'react-native';

class App extends Component {
state=
{
selectedFile:null
}
fileSelectHandler=event=>{
this.setState({
selectedFile:event.target.files[0]
})

}

render() {

return (
    <div className="image-upload">
    <View>
    <Image
     source={require('D:\ofc\firstapp\src\bmw.jpg')}
   />
   </View>

    </div>


);

}
}

export default App;

@KhizerRehan
Copy link

KhizerRehan commented Jun 24, 2018

Trying to build AOT but still unsuccessful! Even tried #7113 solution. But still error persists.kindly help Thanks!
@filipesilva @Brocco

current cli version installed:
screenshot_1

Error screen shot
screenshot_2

@ssjoy76
Copy link

ssjoy76 commented Sep 25, 2018

This command is 100% work for solving this problem.
npm install enhanced-resolve@3.3.0

@rameshpraja
Copy link

I have the same issue
Angular CLI version : 1.0.0
angular version : 4
node : v8.11.3
When I fired ng build --prod then throwing the below error

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/user2/Project/test/streetworkapp/material/loan_calculator/src'
@ ./src/main.ts 5:0-74
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/user2/Project/test/streetworkapp/material/loan_calculator/src/$$_gendir/app/routes/home/home.module.ngfactory.ts' in '/home/user2/Project/test/streetworkapp/material/loan_calculator/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/user2/Project/test/streetworkapp/material/loan_calculator/src/$$_gendir/app/routes/loan/loan.module.ngfactory.ts' in '/home/user2/Project/test/streetworkapp/material/loan_calculator/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

I have tried with upgrading the @angular/cli latest version as well but I am not able to resolved that production issues.

Please expert team help me.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests