Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Error: ./src/app/main.ts Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\Users\Joish\Documents\angular\gait\src\app' #1317

Closed
Joish opened this issue Nov 18, 2017 · 14 comments

Comments

@Joish
Copy link

Joish commented Nov 18, 2017

I have no idea what's going wrong...?
can any of u help

C:\Users\Joish\Documents\angular\gait>ionic cordova build android --prod --release
Running app-scripts build: --prod --platform android --target cordova
[14:07:31] build prod started ...
[14:07:31] clean started ...
[14:07:31] clean finished in 4 ms
[14:07:31] copy started ...
[14:07:32] deeplinks started ...
[14:07:32] deeplinks finished in 38 ms
[14:07:32] ngc started ...
[14:07:37] ngc finished in 5.49 s
[14:07:37] preprocess started ...
[14:07:37] preprocess finished in 1 ms
[14:07:37] webpack started ...
[14:07:37] copy finished in 5.84 s
Error: ./src/app/main.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\Users\Joish\Documents\angular\gait\src\app'
resolve './app.module.ngfactory' in 'C:\Users\Joish\Documents\angular\gait\src\app'
using description file: C:\Users\Joish\Documents\angular\gait\package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Users\Joish\Documents\angular\gait\package.json (relative path: ./src/app)
using description file: C:\Users\Joish\Documents\angular\gait\package.json (relative path: ./src/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory.json doesn't exist
as directory
C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory doesn't exist
[C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory]
[C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory.ts]
[C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory.js]
[C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory.json]
[C:\Users\Joish\Documents\angular\gait\src\app\app.module.ngfactory]
@ ./src/app/main.ts 2:0-60
at BuildError.Error (native)
at new BuildError (C:\Users\Joish\Documents\angular\gait\node_modules@ionic\app-scripts\dist\util\errors.js:16:28)
at callback (C:\Users\Joish\Documents\angular\gait\node_modules@ionic\app-scripts\dist\webpack.js:121:28)
at emitRecords.err (C:\Users\Joish\Documents\angular\gait\node_modules\webpack\lib\Compiler.js:269:13)
at Compiler.emitRecords (C:\Users\Joish\Documents\angular\gait\node_modules\webpack\lib\Compiler.js:375:38)
at emitAssets.err (C:\Users\Joish\Documents\angular\gait\node_modules\webpack\lib\Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (C:\Users\Joish\Documents\angular\gait\node_modules\webpack\lib\Compiler.js:368:12)
at next (C:\Users\Joish\Documents\angular\gait\node_modules\tapable\lib\Tapable.js:218:11)
at Compiler.compiler.plugin (C:\Users\Joish\Documents\angular\gait\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (C:\Users\Joish\Documents\angular\gait\node_modules\tapable\lib\Tapable.js:222:13)

@wjacksondocuwrx
Copy link

Did you try ./node_modules/.bin/ngc? That worked for me.

@Joish
Copy link
Author

Joish commented Nov 20, 2017

could you be more specific...?
what would have cause this error...?
Its keeps bothering me....

@mburger81
Copy link
Contributor

Hi @Joish there are already one closed an reopened bug for your bug. I think you could jump there instead of opening others, what do you think?
This is the closed: #1309 and this is the new opened bug #1315

@lucastelnovo
Copy link

+1

I'm dealing with the same problem. I've been stucked for a week with this and still can't find a solution.

Everything works ok when I run
ionic cordova run android

but when I run
ionic cordova run android --prod

i get the following error:
Error: ./src/app/main.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in '/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app'
resolve './app.module.ngfactory' in '/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app'
using description file: /Users/lucastelnovo/Desarrollo/unipool-client-prod/package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/lucastelnovo/Desarrollo/unipool-client-prod/package.json (relative path: ./src/app)
using description file: /Users/lucastelnovo/Desarrollo/unipool-client-prod/package.json (relative path: ./src/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory.json doesn't exist
as directory
/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory doesn't exist
[/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory]
[/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory.ts]
[/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory.js]
[/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory.json]
[/Users/lucastelnovo/Desarrollo/unipool-client-prod/src/app/app.module.ngfactory]
@ ./src/app/main.ts 2:0-60
at new BuildError (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at callback (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/@ionic/app-scripts/dist/webpack.js:121:28)
at emitRecords.err (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/webpack/lib/Compiler.js:269:13)
at Compiler.emitRecords (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/webpack/lib/Compiler.js:375:38)
at emitAssets.err (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/webpack/lib/Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/webpack/lib/Compiler.js:368:12)
at next (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/tapable/lib/Tapable.js:222:13)
at Compiler.afterEmit (/Users/lucastelnovo/Desarrollo/unipool-client-prod/node_modules/webpack/lib/Compiler.js:365:9)

What i found strange is that I started a new ionic app with
ionic start myApp _blank
and I could run it in production environment.

However, when I started a new app with the "super" template, without doing any modification in the code, I got the same error output when trying to run with --prod flag.

Does anyone know how can I overcome this?

Thanks in advance
Lucas

@mburger81
Copy link
Contributor

Use ./node_modules/.bin/ngc to figure out your error. This is a workaround which let you survive in meantime.
No idea if and when this would be resolved.
Sorry man

@jdhades
Copy link

jdhades commented Nov 22, 2017

I did not use --prod or --release flag, and it worked for me, now I do not know what problems I may have in the future

@Joish
Copy link
Author

Joish commented Nov 22, 2017

@jdhades Exactly,when I don't use --prod it works completely fine......I have no idea why this error occurs
I have tried all the methods that could possibly exits.....I have also reinstalled my whole ionic..still the error occurs

@flakolefluk
Copy link

flakolefluk commented Nov 23, 2017

If you're having troubles with the "super" template, take a look at this.
ionic-team/starters#20
There's a duplicate CardsPageModule. Removing ./src/pages/cards/card.module.ts should fix it (this is a duplicate of ./src/pages/cards/cards.module.ts)

@george19gt
Copy link

george19gt commented Nov 25, 2017

Use ./node_modules/.bin/ngc to figure out your error. The problem is for lazy loading pages... when you create a page it generates the file module.ts, the solution that worked for me was to delete the files module.ts (ex: module.test.ts) and remove @IonicPage() from test.ts

Edit: this happens when you declare the pages in the app.module.ts, at less you use lazy loading it is not necessary to declare it in the app.module.ts

Regards
Jorge de León

@lucasvanhalst
Copy link

Thanks @george19gt that was useful. Pretty annoying that the real error is nowhere to be found when building with --prod.

@danbucholtz
Copy link
Contributor

This is fixed in 3.1.4.

Thanks,
Dan

@yajuve
Copy link

yajuve commented Dec 2, 2017

Thanks @flakolefluk

@Joish
Copy link
Author

Joish commented Dec 2, 2017

Thanks everyone.........

@MarcioQuimbundo
Copy link

In my case, I updated @ionic/app-scripts to version 3.1.4 and works perfectly.

(cmd)on windows:
C:\your_app_path> npm install @ionic/[email protected]

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