ionic2常见问题汇总之安装篇

《ionic2常见问题汇总之安装篇》

如何安装ionic?

## 系统包管理器,安装npm
apt-get install npm nodejs

## 修正nodejs快捷方式
ln -s /usr/bin/nodejs /usr/bin/node

## 更换国内软件源
npm -g install nrm

nrm ls

nrm use taobao

npm install -g npm@3.8.0

## Nodejs包管理器,安装ionic
npm -g install cordova

npm -g install ionic@beta

ionic@beta安装Error无法运行怎么解决?

npm ERR! ionic@2.0.0-beta.23 postinstall: `node lib/tasks/postinstall`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the ionic@2.0.0-beta.23 postinstall script.
npm ERR! This is most likely a problem with the ionic package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node lib/tasks/postinstall
npm ERR! You can get their info via:
npm ERR!     npm owner ls ionic
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.16.0-4-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ionic@beta"
npm ERR! cwd /root/ionic2Project
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /root/ionic2Project/npm-debug.log
npm ERR! not ok code 0

windows 解决方案

npm install -g npm@3.8.0

npm cache clean

npm install -g cordova

npm install -g ionic@beta

debian 解决方案

npm install -g npm@3.8.0

npm cache clean

npm install -g cnpm --registry=http://registry.npm.taobao.org

cnpm install -g cordova

cnpm install -g ionic@beta

安装提示root用户没有权限访问node-pre-gyp?


sudo cnpm -g install ionic@2.0.0-beta.20 --unsafe-perm

如何生成第一个ionic项目?

## 生成ionic1项目
ionic start project-name

## (可尝试)生成ionic2项目
ionic start project-name --v2

## 运行测试项目
cd project-name
ionic serve -l

生成ionic@beta.23项目报错

Installing npm packages...

Unable to run spawn commandError: spawn npm ENOENT (CLI v2.0.0-beta.23)

http://stackoverflow.com/questions/36238862/enoent-error-when-doing-ionic-start

回滚至 beta 22版本即可

I have the exact same issue. Worked in beta 22.

Reverting to the earlier beta resolved the issue:

npm -g install ionic@2.0.0-beta.22

生成ionic@beta项目报错

npm install package Error

进入项目执行npm包安装命令

cd project-name

cnpm install

无法在真机运行 ionic run android

原因分析:

cordova@5.0.0版本过低,需要升级

npm -g install cordova
ionic platform add android
ionic run
cordova run android

gulp3中graceful-fs版本过低

错误信息

(node:2396) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[1]    2396 bus error (core dumped)  gulp

解决方案

https://forum.ionicframework.com/t/error-running-ionic-serve/50706

https://github.com/gulpjs/gulp/issues/1571

I believe you need to downgrade your node version as Node SASS is not currently up-to-date with Node v6

需要将node降级到 v5版本

npm install -g n
n 5.12.0
微信扫一扫交流

作者:ryanemax
微信关注:ryanemax (刘雨飏)
本文出处:https://romantic-hoover-f991f1.netlify.com/faq/ionic2install/
授权协议: CC BY-SA 4.0