Ionic-cli: Unable to create new Ionic app with @ionic/cli

Created on 12 May 2020  路  22Comments  路  Source: ionic-team/ionic-cli

Description:
Hi.
I've been wanting to create a new ionic app for a while and decided to create a new one since React support came out. I followed the guide from this link: Ionic start

It finalizes with introducing the following steps to run:
npm install -g @ionic/cli cordova-res
ionic start --start-id ID-FOR-CREATION

However running the ionic command (or just writing ionic) fails to run. So essentially the entire ionic cli is not working. I've tested following versions of @ionic/cli: 6.9.0, 6.8.0, 6.7.0 and 6.5.0.

I have noticed weird symbols in the error message, it might have something to do with it?

My current environment:
Windows 10 Pro (en-GB)
Node v14.2.0
NPM 6.14.5

Steps to Reproduce:
npm install -g @ionic/cli cordova-res
ionic start

Output:
C:\Users\ahb\AppData\Roaming\nvm\v14.2.0node_modules\@ionic\clinode_modules\@ionic\utils-fs\dist\index.js:168
exports.pathExists = pathExists;
^

TypeError: Cannot set property pathExists of # which has only a getter
at Object. (C:\Users\ahb\AppData\Roaming\nvm\v14.2.0node_modules\@ionic\clinode_modules\@ionic\utils-fs\dist\index.js:168:20)
 at Module._compile (internal/modules/cjs/loader.js:1176:30)
 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
 at Module.load (internal/modules/cjs/loader.js:1040:32)
 at Function.Module._load (internal/modules/cjs/loader.js:929:14)
 at Module.require (internal/modules/cjs/loader.js:1080:19)
 at require (internal/modules/cjs/helpers.js:72:18)
at Object. (C:\Users\ahb\AppData\Roaming\nvm\v14.2.0node_modules\@ionic\clinode_modules\@ionic\cli-framework\utils\node.js:3:20)
 at Module._compile (internal/modules/cjs/loader.js:1176:30)
 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)

My ionic info:
Unable to run any ionic commands. All of them produce the error above

Most helpful comment

Looks like an incompatibility between tslib 1.12.0 and our FS utility library. I've pinned tslib, which should fix the issue for now.

Please update the Ionic CLI to fix the issue:

npm i -g @ionic/[email protected]

All 22 comments

i have the same issue

edit:
i tried to rollback to an older version with npm cache reset but its still not working any more
i am on MacOS

Me too
(using MacOS)

Error appears always with any command start with $ ionic

Same issue, on macOS Catalina. I created a thread on the forum a bit ago as well:

https://forum.ionicframework.com/t/ionic-cli-typeerror/189272

Same issue on Linux

Same issue on Windows 10

Looks like an incompatibility between tslib 1.12.0 and our FS utility library. I've pinned tslib, which should fix the issue for now.

Please update the Ionic CLI to fix the issue:

npm i -g @ionic/[email protected]

Even updating to 6.9.1 the problem still persists.

Maybe try

npm uninstall -g @ionic/cli 
npm cache clear --force
npm install -g @ionic/[email protected]

If you are still having problems to execute ionic serve or similar commands, do a npm install [email protected] that should solve that issue, right after doing @dwieeb solution.

Ok, @netowp 's suggestion solved my issue when running ionic serve, however ionic cordova build ios is still failing.

    ** BUILD FAILED **

    xcodebuild: Command failed with exit code 65
    [ERROR] An error occurred while running subprocess cordova.

    cordova build ios exited with exit code 65.

@TMarafon That's a separate issue.

I've done the step mentioned by @dwieeb and followed it up with the one by @netowp , but am still getting:

TypeError: Cannot set property pathExists of # which has only a getter

@dwieeb I discovered this issue because we are encountering the same error in a project that is still using the deprecated Ionic CLI (v5.4.16). You mentioned that the issue appears to be an incompatibility between tslib and @ionic/utils-fs. That would explain why we are also experiencing the problem.

Would it be possible to pin tslib and publish a fix to the @ionic/utils-fs library instead of the downstream packages? That would address the problem for us and probably more broadly.

@malorisdead I'm also using a deprecated CLI and pinning tslib didn't work for me.

npm uninstall ionic
npm cache clear --force
npm install -g @ionic/[email protected]

This works for me!!

We are on [email protected] and our pipeline is broken because of this. Setting the tslib version to 1.11.2 locally and globally has not resolved it.

I tried uninstall 6.9.1 and downgrade various versions.

At present 6.0.0. its failing..

Install of tslib also didnt work ..

image

Kindly help me to address the issues

@malorisdead

Would it be possible to pin tslib and publish a fix to the @ionic/utils-fs library instead of the downstream packages?

Unfortunately we use exact versions of @ionic/utils-* dependencies (see 5.4.16's package.json), so we'd have to do a full CLI release.

I would bet this problem will fix itself as this comment suggests a tslib fix is coming soon: https://github.com/microsoft/tslib/issues/102#issuecomment-627679883

You can also follow the issue I created here: https://github.com/microsoft/tslib/issues/103


If you're using an old CLI version, is there a reason you're not using the latest? The Ionic CLI supports all versions of the Ionic Framework and breaking changes are minimal (mostly related to changing the minimum NodeJS version).

In our case, it was a CI pipeline that was using the deprecated version. Since the deprecation happened recently but our builds were unaffected, our devops team considered upgrading to be a low priority. Due to this issue we have now upgraded to 6.9.1 and the issue is resolved for us.

Thank you for clarifying the package dependencies and linking to the associated tslib issues. It seems that this is a much broader problem with the release of tslib 1.12.0. I hope Microsoft releases a patch soon.

I fixed our problem by downgrading to [email protected]

We are using ionic 4.7.1 and getting the pathExists error for anyone trying to install ionic the old way. @dwieeb when you say "The Ionic CLI supports all versions of the Ionic Framework and breaking changes are minimal (mostly related to changing the minimum NodeJS version)." When I've tried to install the new cli with version 4.7.1 specifically, it does not exist. We are not ready to upgrade yet for our released version and now we cannot even have it in development without getting the pathExists error. Any suggestions? Have also tried updating tslib and downgrading per the suggestion above to 4.0.1.

Was this page helpful?
0 / 5 - 0 ratings