daweiMBP:~ dawei$ $sudo npm install -g ionic
npm WARN locking Error: EACCES, open '/Users/dawei/.npm/_locks/ionic-61c0cd50dc7a1457.lock'
npm WARN locking at Error (native)
npm WARN locking /Users/dawei/.npm/_locks/ionic-61c0cd50dc7a1457.lock failed { [Error: EACCES, open '/Users/dawei/.npm/_locks/ionic-61c0cd50dc7a1457.lock']
npm WARN locking errno: -13,
npm WARN locking code: 'EACCES',
npm WARN locking path: '/Users/dawei/.npm/_locks/ionic-61c0cd50dc7a1457.lock' }
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "ionic"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! Attempt to unlock /usr/local/lib/node_modules/ionic, which hasn't been locked
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/dawei/npm-debug.log
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
...and...if you're on a mac (like I am), and still see errors after running these commands, then run this last one and you should be good. (Recommend you try testing before you do this one. I don't like changing the permissions on the ENTIRE /usr/local directory unless it really seems necessary!)
sudo chown -R $USER /usr/local
然后发现如下错误
npm ERR! tar.unpack untar error /var/folders/wh/2xdg6wvd5txbkprv3stwg6r40000gp/T/npm-40778-58f71719/registry.npmjs.org/cordova-app-hello-world/-/cordova-app-hello-world-3.9.0.tgz
npm ERR! tar.unpack untar error /var/folders/wh/2xdg6wvd5txbkprv3stwg6r40000gp/T/npm-40778-58f71719/registry.npmjs.org/npm/-/npm-1.3.4.tgz
分开安装:
daweiMBP:~ dawei$ cordova -v
-bash: cordova: command not found
daweiMBP:~ dawei$ sudo npm install -g cordova
cordova 安装成功
tar.unpack untar error 即解压失败。这主要是由于npm文件夹操作是需要root权限的。
看了stackoverflow主要解决办法为:
sudo chown -R $USER ~/tmp
sudo chown -R $USER /usr/local/lib/node_modules
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local
sudo chown -R $USER /usr/bin/node
sudo chown -R $USER /usr/bin/npm
sudo npm cache clean
试尽各种办法,最后还是手动卸载了再重装了npm 1、sudo npm uninstall npm -g 如果步骤1卸不掉npm了(我就是这种情况) 2、进到npm的安装目录 /usr/local/lib/node_modules/npm/ sudo make uninstall 3、手动重装npm curl -L https://npmjs.com/install.sh | sh 然后,终于搞定了!抓狂啊!
Ionic 安装 helloword 演示以及 ionic 在 android 环境下面导航在最上面解决 方案
1. 配置环境
先安装 node.js
安装 cordova
npm install -g cordova sudo npm install -g cordova 注意:部分同学现在直接使用 npm install -g cordova 发现安装了以后 执行 cordova build
android 的时候 提示需要安装 platform for android-21 sdk ,意思就是需要 最新版本的 sdk
解决方法:
1.更新 sdk (推荐) 翻墙 代理 或者想其他办法
2.Sdk 没法更新的情况下面 可以先卸载当前的 cordova,然后再重新指定版本安装 cordova 3. 下载 sdk 包集成 推荐 http://bbs.phonegap100.com/thread-1566-1-1.html
Android adt 离线包集成 sdk http://bbs.phonegap100.com/thread-1456-1-1.html
卸载 cordova http://bbs.phonegap100.com/thread-1180-1-1.html
重新指定版本 安装 cordova http://bbs.phonegap100.com/thread-1127-1-1.html
npm install -g cordova@4.1.2