【问题标题】:Unable to install Ionic with npm? (Mac OSX El Capitan 10.11.2)无法使用 npm 安装 Ionic? (Mac OSX El Capitan 10.11.2)
【发布时间】:2016-08-26 05:04:16
【问题描述】:

我正在尝试在我的 Mac 上使用 npm 安装 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$ 

有解决办法吗?

【问题讨论】:

  • 我也有同样的问题
  • @ThomasBredillet 自己找到了解决方案。在下面检查我的答案。
  • @ThomasBredillet 我已在Medium 上发布此消息

标签: macos cordova ionic-framework npm


【解决方案1】:

不知道什么是“quickscrape”(在已接受的答案中),但解决方案 as given here 更容易并且对我有用:

sudo chown -R $USER /usr/local/

然后再也不要在 npm 中使用 sudo。

【讨论】:

    【解决方案2】:

    如果您在安装 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 项目:

    ionic start myApp blank

    【讨论】:

    • 我已在Medium 上发布此内容。
    猜你喜欢
    • 2016-04-08
    • 1970-01-01
    • 2016-02-05
    • 2017-01-31
    • 2015-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多