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

Unable to create new Ionic app with @ionic/cli

Open Sbearlin opened this issue 6 years ago • 22 comments

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.0\node_modules@ionic\cli\node_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.0\node_modules\@ionic\cli\node_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.0\node_modules\@ionic\cli\node_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

Sbearlin avatar May 12 '20 19:05 Sbearlin

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

s3ppo avatar May 12 '20 19:05 s3ppo

Me too (using MacOS)

ChokeBilly avatar May 12 '20 19:05 ChokeBilly

Error appears always with any command start with $ ionic

roman-rr avatar May 12 '20 19:05 roman-rr

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

MonoHearted avatar May 12 '20 19:05 MonoHearted

Same issue on Linux

liamplm avatar May 12 '20 19:05 liamplm

Same issue on Windows 10

jeanpfs avatar May 12 '20 19:05 jeanpfs

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]

imhoffd avatar May 12 '20 19:05 imhoffd

Even updating to 6.9.1 the problem still persists.

TMarafon avatar May 12 '20 20:05 TMarafon

Maybe try

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

imhoffd avatar May 12 '20 20:05 imhoffd

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.

netowp avatar May 12 '20 20:05 netowp

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 avatar May 12 '20 20:05 TMarafon

@TMarafon That's a separate issue.

imhoffd avatar May 12 '20 21:05 imhoffd

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

asharm52 avatar May 12 '20 22:05 asharm52

@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.

MechanicalMann avatar May 12 '20 23:05 MechanicalMann

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

AleFons avatar May 13 '20 14:05 AleFons

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

This works for me!!

dmoreno85 avatar May 13 '20 15:05 dmoreno85

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.

stewx avatar May 13 '20 16:05 stewx

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

srinivasangurukannan avatar May 13 '20 17:05 srinivasangurukannan

@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).

imhoffd avatar May 13 '20 18:05 imhoffd

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.

MechanicalMann avatar May 13 '20 19:05 MechanicalMann