HELP! My app has exploded (in size)!



…and by “exploded” I’m talking about the size of the compiled file–it has tripled!!!

I know that something changed, but I’m not sure which change is causing this. My app used to compile and end up with an APK size of about 23MB. The iOS IPA file was about the same size.

However, in the past few days I started seeing file sizes about 3-4 times that. I now have 70MB to 80MB file sizes!

I discovered that the tns_modules folder contains what looks like ALL of the npm_modules, even the ones from the devDependencies section of my package.json file. This is where all the size is coming from. Older versions of my app only have the modules which are needed at runtime in their tns_modules folder.

I know that I updated npm to a newer version, but I went back to a much older version (3.x) and the problem persists, though the file size went down to about 68MB.

Has anyone else run across this? If so, have you solved it?

I’m at a loss. This is happening on both my Windows laptop as well as my MacBook Pro, compiling the same project source files. I’m on NativeScript version 3.3.1 at the moment and am building from the command line (not Sidekick).

Please let me know if you have any tips to solve this or have some additional suggestions to try, or need additional information.

Thank you!



I had hit this before but not recently. Sometimes NPM copies the tns-core-modules package inside app folder that messes entire compilation, not sure whether your case is the same. Make sure you don’t have unwanted files inside your app folder and your package.json inside app folder remains untouched.



Here’s a few things you could try:

  1. Update the nativescript CLI to 3.4.2
    1.? Update the npm package to 4.x - npm i npm@4 -g
  2. Start a clean slate rm -rf node_modules/ platforms/android
  3. Build again
  4. ???
  5. Profit


Thanks for the suggestions! I noticed that the package-lock.json file had been updated right before the time when the file size exploded. All of the "dev": true settings had been removed, and so NativeScript couldn’t tell which packages were needed for production versus development, so all packages were included.

I deleted my package-lock.json file and regenerated it, but it still does not contain the "dev": true settings.

However, if I run npm ls --prod --depth=0 the result is the list of dependencies which should be included in the tns_modules folder when I build my app. Something knows the difference between dependencies and devDependencies, but the process that builds my app does not seem to know.

Any other suggestions?




What does the package.json’s dependencies and devDependencies look like? The nativescript CLI will only copy the entries dependencies, and dependencies of dependencies to the tns_modules in platforms/android.


The package.json file had not changed, which is why this is so strange. The dependencies and devDependencies still have their respective packages in them, and like I mentioned, if I run npm ls --prod I will see the contents of the dependencies section, and if I run npm ls --dev I will see the contents of the devDependencies section (plus their dependencies, of course).

But the resulting package-lock.json file doesn’t seem to care whether a dependency came from the devDependencies section–it does not mark the development dependencies with "dev": true.

Similarly, when I build my app, NativeScript doesn’t seem to care whether a dependency came from the devDependencies section or not–all dependencies are included in the tns_modules folder.

One of my coworkers thinks that this may be a code issue on our side, so I’m going to do some more digging to see what else was checked in shortly before the build sizes exploded. Thank you again for your help! Feel free to offer additional suggestions if you have them!



If you suspect the package-lock.json is to blame, although I highly doubt that as there is unlikely to be a notion for package-lock.json in the CLI’s logic, then I’d advice you to downgrade npm to 4.x, removing the package-lock and trying again.


Ok, I discovered the issue that was causing this. I had made an update to a NativeScript plug in which was being included in my project, and that update had added @angular/compiler-cli to the dependencies section of the plug-in’s package.json file. Because of this, my app was including @angular/compiler-cli and all of its dependencies (which are numerous!) as full-fledged dependencies and not as devDependencies.

It’s interesting that a change to a plug-in had this effect, but it makes sense.

Thank you, all, for chiming in with suggestions, especially you, @Pete.K!



It’s great to hear that you figured it out! Mind sharing which plugin that was?


We needed to update the Adobe Marketing Cloud plugin to add a couple things that it didn’t support, yet (I’ve promised a pull request to @spike1292). So I should stress that the plugin as you would find it on NPM or Github would not cause your app to triple in size–this was a side effect of a change that I made to a local copy of the plugin.