无法用npm安装Ionic? (Mac OSX El Capitan 10.11.2)

时间:2016-05-01 10:03:53

标签: macos cordova ionic-framework npm

我正在尝试使用npm在我的Mac上安装Ionic,运行OSX El Capitan 10.11.2。

sudo npm install -g cordova ionic

已经安装了Cordova,我确实输入了正确的密码。以下是错误消息和日志:

Last login: Sun May  1 18:41:17 on ttys001
egaumbp:~ gg$ sudo npm install -g cordova ionic
Password:
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
/usr/local/bin/ionic -> /usr/local/lib/node_modules/ionic/bin/ionic

> node-sass@3.4.2 install /usr/local/lib/node_modules/ionic/node_modules/node-sass
> node scripts/install.js

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
path.js:424
var path = (i >= 0) ? arguments[i] : process.cwd();
                                             ^

Error: EACCES: permission denied, uv_cwd
at Error (native)
at Object.posix.resolve (path.js:424:50)
at startup (node.js:96:32)
at node.js:968:3
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! node v4.4.1
npm ERR! npm  v2.14.20
npm ERR! code ELIFECYCLE

npm ERR! node-sass@3.4.2 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@3.4.2 install script 'node scripts/install.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/gg/npm-debug.log
egaumbp:~ gg$ 

有解决方案吗?

2 个答案:

答案 0 :(得分:7)

如果您在安装Ionic时遇到问题,可能需要查看我在安装时写的文章:https://medium.com/@gautham.gg/how-to-install-ionic-on-mac-without-issues-3efe92a0da93#.yh5zsay13 以下是该文章的摘要:

先决条件:必须安装npm。您可以输入以下命令来检查:'npm -v'。这应该给你版本号。如果没有,请安装它们。

现在让我们解决问题。

首先启动此命令:

sudo npm install --global --unsafe-perm quickscrape

然后,启动此命令:

sudo npm install -g cordova ionic --unsafe-perm quickscrape

现在,运行此命令:

sudo npm install -g ionic --unsafe-perm node-sass

一旦我这样做,Ionic工作得很漂亮。这是在运行OSX El Capitan 10.11.2的MacBook Pro(Retina,13英寸,2012年末)上完成的。 我不确定Windows用户是否对此有任何问题,但我相信如果您在Windows上执行此操作,则应删除“sudo”。

现在你已经按照我的步骤,Ionic和Cordova都应该安装并正常工作。首先创建一个空白的离子项目:

ionic start myApp blank

答案 1 :(得分:2)

不知道' quickscrape' (在接受的答案中)是,但解决方案as given here更容易并为我工作:

sudo chown -R $USER /usr/local/

然后再也不用再使用sudo。