--prod build not work, @ionic/app-scripts 3.0.0 broken

I think that @ionic/app-scripts 3.0.0 are really broken.
I’m posting here to see if I’m the only one is having this problem.

I start a fresh new “blank” app

ionic start app-scripts-tests blank

When I run

ionic cordova build android --prod --verbose

I get the following:

[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/killerchip/dev/temp/app-script-tests', local: false, binPath: 
        '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: '/usr/local/lib/node_modules/ionic/dist/index.js' }
[INFO] Running app-scripts build: --prod --platform android --target cordova
       
[12:46:38]  build prod started ... 
[12:46:38]  clean started ... 
[12:46:38]  clean finished in 2 ms 
[12:46:38]  copy started ... 
[12:46:38]  deeplinks started ... 
[12:46:38]  deeplinks finished in 30 ms 
[12:46:38]  ngc started ... 
[12:46:44]  ngc finished in 5.99 s 
[12:46:44]  preprocess started ... 
[12:46:44]  copy finished in 6.11 s 
[12:46:44]  preprocess finished in 78 ms 
[12:46:44]  webpack started ... 
[12:47:05]  webpack finished in 21.04 s 
[12:47:05]  uglifyjs started ... 
[12:47:05]  sass started ... 
[12:47:07]  sass finished in 1.48 s 
[12:47:07]  cleancss started ... 
[12:47:16]  cleancss finished in 9.20 s 
[12:47:18]  uglifyjs finished in 12.61 s 
[12:47:18]  postprocess started ... 

And then it is giving me the… “prompt” again

Building without the –prod parameter works fine.

The same goes with my production app. And I had this problem since @ionic/app-scripts v2.1.4.

Right now in production app I’m using Ionic 3.6.1 with @ionic/app-scripts v2.0.1 which works.

If I upgrade my Ionic framework to 3.7.1 but keep the @ionic/app-scripts v2.0.1, then building does not work at all and gives an error about deeplinks (I guess that is expected).

So I’m stuck with v3.6.1 of Ionic if I want to build production versions.

My current ionic info for the app-scripts-tests app is:

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.13.0
    ionic (Ionic CLI) : 3.13.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.7.1

System:

    Android SDK Tools : 26.0.1
    ios-deploy        : 1.9.2 
    ios-sim           : 5.0.13 
    Node              : v6.10.2
    npm               : 3.10.10 
    OS                : macOS Sierra
    Xcode             : Xcode 9.0 Build version 9A235 

Misc:

    backend : legacy

Is anyone else experiencing this inability to build production packages?
To my understanding this is a big thing, but I don’t see any uproar, so I was wondering if it is something specific to my environment.

Thank you in advance.

Can you try on another computer?
Run npm run ionio:build --prod --verbose and post the output.

@ionic/app-scripts 3.0.0 isn’t broken, could confirm it works fine with my app.

Since you are facing a problem while using -prod, have you noticed the change described in the CHANGELOG of the version? Respectively do you have a local custom webpack.config.js? If so, while upgrading app-script to 3.0.0 you will have to upgrade this file too, see

Reference:

@reedrichards thank you very much for your response.

I think it is something specific to my environment and not my app. Apart from the fact that I’m not using webpack.config.js at all, the worrying thing is that I cannot build even the “blank” ionic template as I described above. (and it was created just a few minutes before my original post).

Thank you all for your responses.

I will try to run on another computer as soon as I can…

In the meantime I run npm run ionic:build --prod --verbose

It “spits” a

Error: ENOENT: no such file or directory, open '/Users/killerchip/dev/temp/app-script-tests/www/build/main.js.map'
    at Error (native)

I’m suspecting it is related to the following issue:

I’m indeed curious what the result would be running on another computer.

Here’s the whole result:

npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--prod',
npm verb cli   '--verbose' ]
npm info using npm@3.10.10
npm info using node@v6.10.2
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle app-script-tests@0.0.1~preionic:build: app-script-tests@0.0.1
npm info lifecycle app-script-tests@0.0.1~ionic:build: app-script-tests@0.0.1

> app-script-tests@0.0.1 ionic:build ******masked****/app-script-tests
> ionic-app-scripts build

[14:30:19]  ionic-app-scripts 3.0.0 
[14:30:19]  build prod started ... 
[14:30:19]  clean started ... 
[14:30:19]  clean finished in 2 ms 
[14:30:19]  copy started ... 
[14:30:19]  deeplinks started ... 
[14:30:19]  deeplinks finished in 36 ms 
[14:30:19]  ngc started ... 
[14:30:25]  ngc finished in 5.25 s 
[14:30:25]  preprocess started ... 
[14:30:25]  copy finished in 5.34 s 
[14:30:25]  preprocess finished in 70 ms 
[14:30:25]  webpack started ... 
[14:30:45]  webpack finished in 20.01 s 
[14:30:45]  uglifyjs started ... 
[14:30:45]  sass started ... 
[14:30:46]  sass finished in 1.41 s 
[14:30:46]  cleancss started ... 
[14:30:55]  cleancss finished in 9.23 s 
[14:30:57]  uglifyjs finished in 12.39 s 
[14:30:57]  postprocess started ... 
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '******masked****/app-script-tests/www/build/main.js.map'
    at Error (native)

npm verb lifecycle app-script-tests@0.0.1~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle app-script-tests@0.0.1~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:******masked****/app-script-tests/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:******masked****Library/Android/sdk/platform-tools:******masked****Library/Android/sdk/tools
npm verb lifecycle app-script-tests@0.0.1~ionic:build: CWD: ******masked****/app-script-tests
npm info lifecycle app-script-tests@0.0.1~ionic:build: Failed to exec ionic:build script
npm verb stack Error: app-script-tests@0.0.1 ionic:build: `ionic-app-scripts build`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at EventEmitter.emit (events.js:191:7)
npm verb stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at ChildProcess.emit (events.js:191:7)
npm verb stack     at maybeClose (internal/child_process.js:886:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid app-script-tests@0.0.1
npm verb cwd ******masked****/app-script-tests
npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ionic:build" "--prod" "--verbose"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! app-script-tests@0.0.1 ionic:build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app-script-tests@0.0.1 ionic:build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the app-script-tests package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs app-script-tests
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls app-script-tests
npm ERR! There is likely additional logging output above.
npm verb exit [ 1, true ]

npm ERR! Please include the following file with any support request:
npm ERR!     ******masked****/app-script-tests/npm-debug.log

Forgot to mention, that all the above results are on the “blank” template app. Not my own production app.

which node/npm/cordova version are you using?

like I said I don’t face any problem, running ionic cordova build ios/android --prod works fine for me. I’m up-to-date with all libs and frameworks

sorry that I can’t help more, good luck and hope you’ll find a solution soon

Could this be a permission problem maybe somehow?
It might be worth uninstalling node and installing nvm, then reinstall everything in a new node via that.

1 Like

@reedrichards @Sujan12

Your answers were helpful enough.
So it must be something with my environment, since other people does not have problem.

I will try with another computer, and also try to remove and re-install everything.

BTW, I tried also “sudo npm run ionic:build --prod” but I got the same results :frowning:

Thanks again guys
:slight_smile:

1 Like

OK. I tested in another Windows 10 laptop i have.
It works even with not the latest and greatest npm, node, etc.

So it must be something in my Mac environment :thinking:

@killerchip I would recommend nuking node and npm completely on your mac, then reinstalling the latest from nodejs.org. It could be your node v6 / npm v3, those are the only major differences I see between our ionic info.

Once upgraded, follow the ionic installation and tutorial guides (aka npm install -g ionic and ionic start test-app).

Once you do that, add a platform and try a build with --prod.

My ionic info:

    @ionic/cli-utils  : 1.13.1
    ionic (Ionic CLI) : 3.13.1

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.7.1

System:

    ios-deploy : 1.9.1 
    ios-sim    : 5.0.13 
    Node       : v7.4.0
    npm        : 4.0.5 
    OS         : macOS Sierra
    Xcode      : Xcode 9.0 Build version 9A235 

Misc:

    backend : legacy

If you are nuking stuff, make the jump to nvm as well:

Uninstall your node, install nvm (or nvm-windows if you are on Windows), install a new node (which includes npm) with this, then install ionic and cordova again and try your command again. The problem should be gone.

2 Likes