Ionic Pro DOES NOT support `engines` on `package.json` to define node and npm versions

I discovered over the hardest way that Ionic Pro does NOT support engines in package.json.
There is no documentation explaining the behavior though.
I found this when using cordova as devDependency.

After getting in touch with Ionic support, together we discovered that cordova sneaks into an older version of npm when it is defined as a project dependency like:

{// ...
  "devDependencies": {
    // ...
    "cordova": "^7.1.0",
    // ...

I did put cordova as devDependency because I was switching development machines often.
But when doing it and deploying into IonicPro cordova was using an older npm version that it was listing as it’s own dependency.

I temporarily solved this by setting the engines field in package.json which told cordova to use the correct npm version, but this is just a workaround and the solution is to remove cordova from devDependencies and let ionic use the global cordova on the environment.

So this post remains as a warning for anyone wondering why a deploy may use different versions of npm.

So DO NOT specify cordova as a dependency or devDependency of your project when deploying to Ionic Pro. Things will go wrong if so.


Previows wrong thoughts

As suggested below I’m giving an example of how to use this in your project.

Before pushing your changes to ionic you can add an engines field in package.json in order to tell Ionic Pro that your project compiles under certain versions of npm and node.

At the time of writing this the latest version of node is 9.2.0 and npm is at 5.5.1, so if you want to compile your project against this versions you can put this in your package.json:

  "engines": {
    "node": ">=9.2.0",
    "npm": "5.5.1"

This kind of configuration can help speed up your builds with newer versions, utilize newer features with newest libs and tools and avoid dependency errors during compilation.

This seems more like a Github issue than a forum post. The devs may or may not read this.

What can you do with that?

Where can I find any repo on GitHub related to Ionic Pro?
Is there any?

Or do you mean I should post this in the ionic-team/ionic github repo?

I mean… you can specify which node or npm range of versions your project supports and Ionic Pro will compile it in a version that is in that range.

I think there is no Github repo for Ionic Pro.

If you want to tell them to document it, best use

Otherwise: Post an example here and consider it documented :wink:

1 Like

Edited my original post with an example.


1 Like

(Took the liberty to edit the topic title a bit)

1 Like

I cant confirm this behavior. I specified Node.js to be bigger or equal 8.9.3 (current LTS), but still got npm info using node@v8.2.1 :-1:

Well… Would be nice if someone in the core team could explain what happens in Ionic Pro with these config.
But I’m not sure which way it would be more apropriate to approach them in order to clarify this behavior.

Only sure way to contact them is the support form at

I managed to get in touch with the Ionic support and updated the post in conformity with the results.

That got fixed with the release of Cordova CLI 8.0.0 yesterday by the way :wink:

1 Like

If you need particular versions of node and npm, just make them direct dependencies of your project. If your project and cordova depend on different versions of npm, each will use the appropriate version. What you described is what happens when there’s only one version listed as any dependency, so that’s the only version installed. IMO it’s far better to explicitly depend on cordova then implicitly assume every system you ever clone your project on will already have a compatible version.

@ShadSterling the problem was that I had my own needed version of node and npm for my project described in package.json#engines but when cordova used his own version of npm and it was an earlier/outdated/incompatible version of npm it didn’t encountered the needed packages because of changes in the folder structure of node_modules and this prevented the build from happening, then this thread started.

Assuming every system would have the needed versions of node and npm wouldn’t work in my case because I needed npm to have an specific version or later that cordova was trying to use an outdated version.
In my opinion cordova should support all newest versions of npm than that its required and not force to use the outdated version that causes conflict.

If you specify npm in your dependencies, your project will use the specified version. engines is only used if your project is installed as a dependency of another, it has no effect while working on your project. if you depend on, say, npm@5 and one of your dependencies depends on say npm@2, that’s not a conflict, your package and your dependency will use different versions as specified.

Near the end of your post you say “DO NOT specify cordova as a dependency or devDependency”, which means having an implicit dependency on cordova, which means assuming every system you ever clone your project on will already have a compatible version. It is far better to explicitly depend on cordova, and on the version of npm you need.

“It is far better to explicitly depend on cordova, and on the version of npm you need.”
Yes @ShadSterling, I agree with that, and that is why I had put cordova on my devDependencies.
But that caused cordova to ignore the npm version specified on the project package.json and utilize his own version of npm on the Ionic Pro build.

If you will not use the Ionic Pro build system and will distribute it outside Ionic Pro you will not suffer from this issue.
This whole issue is related to Ionic Pro building.

And specifying both cordova and npm versions on the package.json will lead to your build use 2 different versions of npm at build time, leading to cordova not being able to locate some dependencies.

And this was only my experience with 2 different projects that lead to the same behavior.

I can’t confirm this with newer versions of cordova because I just finished the projects and will not work with Ionic for a long time.

That’s bizarre; where I saw cordova depending on npm@2, it never got confused about anything, it used npm@2 and the ionic site used npm@5, and everything worked just fine. This wasn’t Ionic Pro, just Ionic. We’ve since removed cordova from our build, and are now using Ionic without cordova.