ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

app.module.ngfactory failing PRD build

Open vbudilov opened this issue 10 years ago • 63 comments

Short description of the problem:

Getting the following:

[13:28:27]  Error: Could not resolve entry (.tmp/app/main.prod.js)
    at /home/xx/dev/xx/xx/xxx-ionic/node_modules/rollup/dist/rollup.js:8602:28
    at process._tickCallback (internal/process/next_tick.js:103:7)

The AppModuleNgFactory cannot be resolved:

import {AppModuleNgFactory} from "./app.module.ngfactory";

So main.prd.ts doesn't compile and the whole build fails.

I've searched all over and couldn't find an appropriate fix for this issue.

What behavior are you expecting?

I can build the project and run it on android

Steps to reproduce:

  1. ionic run android
insert any relevant code between the above and below backticks

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

Which Ionic Version? 1.x or 2.x v2 RC.0

Run ionic info from terminal/cmd prompt: (paste output below) Cordova CLI: 6.2.0 Ionic Framework Version: 2.0.0-rc.0 Ionic CLI Version: 2.1.0 Ionic App Lib Version: 2.1.0-beta.1 OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Node Version: v6.7.0

npm -v 3.10.8 node -v v6.7.0

vbudilov avatar Sep 29 '16 17:09 vbudilov

Hello, thanks for opening an issue with us! Could you post a repo that I can use to reproduce this issue?

jgw96 avatar Sep 29 '16 17:09 jgw96

I figured it out, but only after creating a completely new project and transferring the components, etc to it. Once I did that, I ran ionic run android and saw the following:

[14:52:21] ngc error: Error: Error at /home/vova/dev/ideas/xxx/xxxx-app/.tmp/pages/auth/auth.ngfactory.ts:3805:29: Supplied parameters do not match any signature of call target.

For some reason this particular log entry isn't showing up in my original project, so I'm assuming there's a parameter that I have to set to verbose (or something to that effect).

Either way, once that was fixed the build was fine.

Any idea what changed from the old version to the new in regards to logging messages?

vbudilov avatar Sep 29 '16 19:09 vbudilov

Nothing that we know of. Glad you were able to get it resolved 😄

I'm going to close this issue.

Thanks, Dan

danbucholtz avatar Sep 29 '16 19:09 danbucholtz

Hello, i have the same issue, attached the error stack

[09:38:27]  Error: Could not resolve entry (.tmp/app/main.prod.js)
    at /Users/koala/Documents/angular/tfc-mobile/node_modules/rollup/dist/rollup.js:8602:28

[09:38:27]  sass started ...
[09:38:31]  sass finished in 4.43 s
[09:38:31]  minify started ...
[09:38:31]  cleancss started ...
[09:38:31]  uglifyjs started ...
[09:38:31]  Error: ENOENT: no such file or directory, open '/Users/koala/Documents/angular/tfc-mobile/www/build/main.js'
    at Error (native)
    at Object.fs.openSync (fs.js:634:18)
    at Object.fs.readFileSync (fs.js:502:33)
    at addFile (/Users/koala/Documents/angular/tfc-mobile/node_modules/uglify-js/tools/node.js:68:22)
    at /Users/koala/Documents/angular/tfc-mobile/node_modules/uglify-js/tools/node.js:79:17
    at Array.forEach (native)
    at Object.exports.minify (/Users/koala/Documents/angular/tfc-mobile/node_modules/uglify-js/tools/node.js:77:26)
    at runUglifyInternal (/Users/koala/Documents/angular/tfc-mobile/node_modules/@ionic/app-scripts/dist/uglifyjs.js:34:19)
    at runUglify (/Users/koala/Documents/angular/tfc-mobile/node_modules/@ionic/app-scripts/dist/uglifyjs.js:23:28)
    at Object.uglifyjs (/Users/koala/Documents/angular/tfc-mobile/node_modules/@ionic/app-scripts/dist/uglifyjs.js:9:12)

It works well if i run ionic serve, but got this error if i run ionic run android

any idea, thanks for the help.

jorgedkoala avatar Oct 03 '16 08:10 jorgedkoala

I have the exact same problem, so it seems this is a problem affecting a number of people.

BiteMyBucket avatar Oct 03 '16 09:10 BiteMyBucket

but if i compile with ionic serve and then run cordova run android --device it works

2016-10-03 11:14 GMT+02:00 BiteMyBucket [email protected]:

I have the exact same problem, so it seems this is a problem affecting a number of people.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/driftyco/ionic/issues/8312#issuecomment-251060551, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8b-UFSTDMcK_HPx3A0yzHnbSh-Rsebks5qwMd5gaJpZM4KKRGx .

jorgedkoala avatar Oct 03 '16 09:10 jorgedkoala

Hello, I'm getting a similar issue when trying to use ionic build as well as when I try to emulate it on ios. Using ionic serve works properly on my local environment.

[12:20:20] Error: Could not resolve entry (.tmp/app/main.prod.js)

scottwittrock avatar Oct 03 '16 16:10 scottwittrock

+1 I have the same issue as well

jasonwaters avatar Oct 03 '16 18:10 jasonwaters

Me too

mola10 avatar Oct 04 '16 12:10 mola10

I too can run ionic serve on my local browser but when trying to run on my android device am getting the same error:

[15:19:15] Error: Could not resolve entry (.tmp/app/main.prod.js) at C:\Users\aberec\ionic_projects\VERSION2\CustomerOverviewMobile\node_modul es\rollup\dist\rollup.js:8602:28 at runMicrotasksCallback (internal/process/next_tick.js:58:5) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) at Module.runMain (module.js:592:11) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3

Please advise us on what to do?

wicketyCode avatar Oct 04 '16 13:10 wicketyCode

Hello all,

Can you try installing the latest app scripts and see if that resolves your issue or provides a better error message?

npm install @ionic/app-scripts@latest

Thanks, Dan

danbucholtz avatar Oct 04 '16 14:10 danbucholtz

I tried the latest release of app-scripts (0.0.28), but I get the same error on prod builds. When checking in the .tmp-dir, I see that it does not contain any .js files (only .ts), so it's probably skipping the transpilation step from typescript to javascript.

EDIT: I found out that I had installed app-scripts globally, which was the 0.0.23 version. When I ran npm run build with the newest 0.0.28, I got the following error:

[16:54:42] ngc failed: Unable to find Angular Compiler "ngc" command: null [16:54:42] Error: Unable to find Angular Compiler "ngc" command: null

I guess these errors were omitted before.

bvx89 avatar Oct 04 '16 14:10 bvx89

For some reason some of the error messages are being omitted, so all you see is that the main.js file is missing. I had to start from a new project (migrating my code to it) in order to see what's actually failing. Basically, something is missing in the instructions on how to migrate your current project to RC0

vbudilov avatar Oct 04 '16 14:10 vbudilov

updated the app-scripts, i also updated the node and npm versions, and got a diferent error, but still dont run. i got this message

Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts build

this is the error compiling

[16:40:39]  ngc error: Compilation failed
[16:40:39]  ngc failed:  NGC encountered an error
[16:40:39]  Error: NGC encountered an error
    at ChildProcess.<anonymous> (/Users/koala/Documents/angular/tfc-mobile/node_modules/@ionic/app-scripts/dist/ngc.js:60:24)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error running ionic app script "build": Error: NGC encountered an error

And here the ionic info

Cordova CLI: 6.3.0
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: Not installed
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 7.1.1 Build version 7B1005 

jorgedkoala avatar Oct 04 '16 15:10 jorgedkoala

@bvx89 and @vbudilov,

Are you running npm 3? We require npm 3 now. I believe that is was in the release notes and instructions but perhaps it slipped through the cracks. Can you run npm --version to verify?

@jorgedkoala,

Dang, that error message is not very helpful 😄 . Can you dig in and see if you can get something else from it? Do you have ${PROJECT_ROOT}/node_modules/@angular/compiler-cli in your project? ngc is pretty strict with processing templates and code, but it doesn't seem to even running in your case.

Thanks, Dan

danbucholtz avatar Oct 04 '16 15:10 danbucholtz

Thanks Dan for the interest, My npm version is 3.10.8 also ${PROJECT_ROOT}/node_modules/@angular/compiler-cli is in the project i'll look 4 more information

jorgedkoala avatar Oct 04 '16 16:10 jorgedkoala

I'm having exactly the same problem as above (when I run ionic build). I noticed that there is a missing module in the main.prod.ts file in the app dir... the AppModuleNgFactory class is imported in the main.prod.ts file but there is no app.module.ngfactory.ts file. I use node v4.6.0 and nvm3.x.x on windows 10.

I tried to create one but really, I am new to all this and all I do fail. please help!!

kamicodaxe avatar Oct 04 '16 16:10 kamicodaxe

If some one can create the constructor in that missing app.module.ngfactory.ts file then I think it might resolve this issue.

kamicodaxe avatar Oct 04 '16 17:10 kamicodaxe

@danbucholtz Yes. I'm running Node v6.7.0 and NPM v3.10.8. I can see the ngc symlink-file inside ${PROJECT_ROOT}/node_modules/.bin/, but it's pointing to the path ../ngc/main.js. As there is no ngc folder inside node_modules, the script fails. Should the ngc symlink point to node_modules/@angular/compiler-cli or something else?

EDIT: Well, I'm not sure what caused the afforementioned problem, but after I deleted node_modules and ran npm install, the path of the ngc-file inside ${PROJECT_ROOT}/node_modules/.bin/ became correct.

By running npm run build I can finally see all my errors inside the project. Thanks for your help!

bvx89 avatar Oct 04 '16 20:10 bvx89

@kami-ruvice,

The ngfactory.ts file missing is because that file is never used until after ngc runs. I am not in love with the way this works (build error by default until ngc runs) but it is how Angular does it and recommends doing it. This main change in a future iteration as I know Angular is making some changes to the ngc process.

Can everyone make sure there package.json entry for @ionic/app-scripts is set to latest? We're iterating really fast there and releasing often. Can you blow away your node_modules and do a fresh npm install and see if everything is resolved?

Also try blowing away the .tmp directory.

Thanks, Dan

danbucholtz avatar Oct 04 '16 21:10 danbucholtz