[英]Ionic/Angular Issue Cannot find module './fs'
I have installed node v10 and trying to install Ionic in my mac. 我已经安装了节点v10,并尝试在Mac中安装Ionic。
When I run sudo npm install -g ionic
, it shows ionic 4 installed successfully. 当我运行
sudo npm install -g ionic
,它表明ionic 4安装成功。
But when run ionic -v
or ionic serve
, it shows the following error 但是当运行
ionic -v
或ionic serve
,它显示以下错误
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. @Edric Comment帮助了我。
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. 我卸载了ionic并没有安装sudo而重新安装,现在它的运行非常好。
Thank you @Edric. 谢谢@Edric。
The reason you are facing this issues is because you have installed Ionic with root permission. 遇到此问题的原因是因为您具有root权限安装了Ionic。 So
ionic -v
is not able to access installed files. 因此,
ionic -v
无法访问已安装的文件。
Try with sudo
ie sudo ionic -v
尝试使用
sudo
即sudo ionic -v
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.