Mac Cordova 开发 APP环境配置

cordova安装与配置

       参数说明

  1. cordova需要node安装,使用Safari打开nodejs.org,下载并安装  在终端输入node -v命令查看是否安装成功,出现版本号就代表安装成功了.
  2. 安装完成后需要从终端下载cordova,输入下面的命令就可以安装完成cordova :命令为: sudo npm install -g cordova
  3. 在终端使用 cordova -v  会出现以下错误    

    /usr/local/lib/node_modules/cordova/node_modules/insight/node_modules/configstore/index.js:53

    throw err;

    ^

     

    Error: EACCES: permission denied, open '/Users/zhekexinxi/.config/configstore/insight-cordova.json'

    You don't have access to this file.

     

        at Object.fs.openSync (fs.js:646:18)

        at Object.fs.readFileSync (fs.js:551:33)

        at Configstore.get (/usr/local/lib/node_modules/cordova/node_modules/insight/node_modules/configstore/index.js:34:26)

        at new Configstore (/usr/local/lib/node_modules/cordova/node_modules/insight/node_modules/configstore/index.js:27:45)

        at new Insight (/usr/local/lib/node_modules/cordova/node_modules/insight/lib/index.js:38:34)

        at Object.<anonymous> (/usr/local/lib/node_modules/cordova/src/telemetry.js:26:15)

        at Module._compile (module.js:652:30)

        at Object.Module._extensions..js (module.js:663:10)

        at Module.load (module.js:565:32)

        at tryModuleLoad (module.js:505:12)

    zhekexinxideMac-mini:~ zhekexinxi$ touch helloworld.js

    zhekexinxideMac-mini:~ zhekexinxi$ vim helloworld.js

    zhekexinxideMac-mini:~ zhekexinxi$ node helloworld.js

    Server running at http://127.0.0.1:1337/

    ^[:wq

    exit    

    ^C     上提示是权限够不,但是当你添加sudo之后,后续仍然其他的权限问题.当你依次添加sudo的执行后,生成的文件却没有权限打开.看来要换另外一个办法来解决了

    解决方法:

    sudo chown -R $USER:$GROUP ~/.npm

    sudo chown -R $USER:$GROUP ~/.config

  4. 新建项目

  5. 我们新建一个HelloWorld项目,在终端中输入
  6. cordova create hello com.example.hello HelloWorld

名称必填描述
hello必填工程的文件夹名,会创建一个同名文件夹
com.example.hello可选应用程序的id名,与Xcode中类似,可以在 config.xml 中修改,如果不指定的话默认为 io.cordova.hellocordova
HelloWorld可选App的名称,也可在 config.xml 中修改
  1.    
  2. 通过上面的命令会创建一个HelloWorld的文件夹,在终端中输入以下命令添加ios开发
  3. cd HelloWorld cordova platform add ios

    运行项目

  8. 一种方法是在终端输入命令

  1. 一种方法是在终端输入命令   cordova run ios
  2.  另外一种方法是在Xcode中打开HelloWorld项目并点▶️键

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值