Error installing ionic on mac

#1

I am getting error while installing ionic on my mac machine.
I have installed all the softwares required for ionic, but still ionic is not getting isntalled:
node js : v10.14.1
npm : 6.4.1
cordova : 8.1.2
java : 11.0.1

Command : sudo npm install -g ionic

I have also attached the log file for the same :

Log error :
0 info it worked if it ends with ok

1 verbose cli [ ‘/usr/local/bin/node’,

1 verbose cli ‘/usr/local/bin/npm’,

1 verbose cli ‘install’,

1 verbose cli ‘-g’,

1 verbose cli ‘ionic’ ]

2 info using npm@6.4.1

3 info using node@v10.14.1

4 verbose npm-session 92be60f19856acf3

5 silly install loadCurrentTree

6 silly install readGlobalPackageData

7 http fetch GET 304 https://registry.npmjs.org/ionic 345ms (from cache)

8 silly fetchPackageMetaData error for ionic@latest Unexpected end of JSON input while parsing near ‘…f00c4eb79e76fee51497a’

9 timing stage:rollbackFailedOptional Completed in 0ms

10 timing stage:runTopLevelLifecycles Completed in 503ms

11 verbose stack SyntaxError: Unexpected end of JSON input while parsing near ‘…f00c4eb79e76fee51497a’

11 verbose stack at JSON.parse (<anonymous>)

11 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)

11 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)

11 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)

12 verbose cwd /Users/jaspreet

13 verbose Darwin 17.7.0

14 verbose argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” “-g” “ionic”

15 verbose node v10.14.1

16 verbose npm v6.4.1

17 error Unexpected end of JSON input while parsing near ‘…f00c4eb79e76fee51497a’

18 verbose exit [ 1, true ]

#2
#3

Hi,
I have tried the above commands as well, but still the same error persists.

#4

I might consider deleting node and npm and starting fresh.

#5

I recommend never using sudo with anything Ionic-related. I use and recommend nvm for managing node installations. Finally, AFAIK, cordova requires Java 8, so 11 won’t work.

1 Like