I have installed node v10 and trying to install Ionic in my mac.
When I run sudo npm install -g ionic
, it shows ionic 4 installed successfully.
But when run ionic -v
or ionic serve
, it shows the following error
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module './fs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/fs-extra/lib/index.js:6:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
I have searched for the solution but I could not find any working solution for me.
Any help is appreciated.
@Edric Comment helped me out.
It is strongly advised to not run npm install -g with sudo.
I uninstalled the ionic and reinstalled without sudo and now it is working just great.
Thank you @Edric.