如何在phonegap中创建项目时删除错误

时间:2014-03-25 12:24:35

标签: cordova

我在使用cordova 3.4时创建了一个项目。

这是我的日志;

Last login: Tue Mar 25 11:42:04 on console
MAC9s-Mac-mini:~ naveen$ $ sudo npm install -g cordova
-bash: $: command not found
MAC9s-Mac-mini:~ naveen$ sudo npm install -g cordova

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
npm http GET https://registry.npmjs.org/cordova
npm http 200 https://registry.npmjs.org/cordova
npm http GET https://registry.npmjs.org/cordova/-/cordova-3.4.0-0.1.3.tgz
npm http 200 https://registry.npmjs.org/cordova/-/cordova-3.4.0-0.1.3.tgz
npm http GET https://registry.npmjs.org/plist-with-patches
npm http GET https://registry.npmjs.org/xcode/0.6.6
npm http GET https://registry.npmjs.org/shelljs
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/semver
npm http GET https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/npmconf

npm http 200 https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.5.tgz
npm http 200 https://registry.npmjs.org/dep-graph/-/dep-graph-1.1.0.tgz
npm http 200 https://registry.npmjs.org/npm/-/npm-1.3.4.tgz
npm http 200 https://registry.npmjs.org/glob/-/glob-3.2.9.tgz
npm http 200 https://registry.npmjs.org/request/-/request-2.22.0.tgz
npm http 200 https://registry.npmjs.org/rc/-/rc-0.3.0.tgz
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/proto-list
npm http 200 https://registry.npmjs.org/abbrev
npm http 200 https://registry.npmjs.org/proto-list
npm http GET https://registry.npmjs.org/proto-list/-/proto-list-1.2.2.tgz
npm http GET https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/rimraf
npm http 200 https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
npm http 200 https://registry.npmjs.org/proto-list/-/proto-list-1.2.2.tgz
npm http 200 https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz
npm http 200 https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz
npm http 200 https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz
npm http 200 https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz
npm http GET https://registry.npmjs.org/ctype/0.5.2
npm http GET https://registry.npmjs.org/assert-plus/0.1.2
npm http GET https://registry.npmjs.org/asn1/0.1.11
npm http GET https://registry.npmjs.org/hoek
npm http GET https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/sntp
npm http GET https://registry.npmjs.org/combined-stream
npm http GET https://registry.npmjs.org/async
npm http 200 https://registry.npmjs.org/ctype/0.5.2
npm http 200 https://registry.npmjs.org/asn1/0.1.11
npm http 200 https://registry.npmjs.org/assert-plus/0.1.2
npm http GET https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz
npm http GET https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz
npm http GET https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz
npm http 200 https://registry.npmjs.org/combined-stream
npm http GET https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz
npm http 200 https://registry.npmjs.org/sntp
npm http GET https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz
npm http 200 https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz
npm http 200 https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz
npm http 200 https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz
npm http 200 https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz
npm http 200 https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz
npm http 200 https://registry.npmjs.org/async
npm http 200 https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz
npm http GET https://registry.npmjs.org/async/-/async-0.2.10.tgz
npm http 200 https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/boom/-/boom-0.4.2.tgz
npm http 200 https://registry.npmjs.org/hoek
npm http GET https://registry.npmjs.org/hoek/-/hoek-0.8.5.tgz
npm http 200 https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz
npm http 200 https://registry.npmjs.org/async/-/async-0.2.10.tgz
npm http 200 https://registry.npmjs.org/boom/-/boom-0.4.2.tgz
npm http 200 https://registry.npmjs.org/hoek/-/hoek-0.8.5.tgz
npm http GET https://registry.npmjs.org/delayed-stream/0.0.5
npm http GET https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz
npm http 200 https://registry.npmjs.org/delayed-stream/0.0.5
npm http GET https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz
npm http 200 https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz
npm http 200 https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/deep-extend
npm http GET https://registry.npmjs.org/ini
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/underscore/1.2.1
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/forever-agent
npm http GET https://registry.npmjs.org/tunnel-agent
npm http GET https://registry.npmjs.org/http-signature
npm http GET https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/hawk
npm http GET https://registry.npmjs.org/oauth-sign
npm http GET https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/form-data/0.0.8
npm http GET https://registry.npmjs.org/cookie-jar
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/ini
npm http 200 https://registry.npmjs.org/deep-extend
npm http 200 https://registry.npmjs.org/underscore/1.2.1
npm http GET https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.8.tgz
npm http GET https://registry.npmjs.org/underscore/-/underscore-1.2.1.tgz

npm http GET https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz
npm http 200 https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz
npm http 304 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/delayed-stream/0.0.5
npm http 200 https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz
npm http 200 https://registry.npmjs.org/lru-cache/-/lru-cache-2.5.0.tgz
npm http 304 https://registry.npmjs.org/delayed-stream/0.0.5
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
cordova@3.4.0-0.1.3 /usr/local/lib/node_modules/cordova
├── mime@1.2.11
├── q@0.9.7
├── semver@2.0.11
├── underscore@1.4.4
├── shelljs@0.1.4
├── optimist@0.6.0 (wordwrap@0.0.2, minimist@0.0.8)
├── plist-with-patches@0.5.1 (xmlbuilder@0.4.3, xmldom@0.1.19)
├── npmconf@0.1.13 (once@1.3.0, inherits@2.0.1, osenv@0.0.3, ini@1.1.0, mkdirp@0.3.5, nopt@2.2.0, config-chain@1.1.8)
├── xcode@0.6.6 (node-uuid@1.3.3, pegjs@0.6.2)
├── tar@0.1.19 (inherits@2.0.1, block-stream@0.0.7, fstream@0.1.25)
├── elementtree@0.1.5 (sax@0.3.5)
├── request@2.21.0 (json-stringify-safe@4.0.0, aws-sign@0.3.0, forever-agent@0.5.2, qs@0.6.6, tunnel-agent@0.3.0, oauth-sign@0.3.0, cookie-jar@0.3.0, node-uuid@1.4.1, http-signature@0.9.11, form-data@0.0.8, hawk@0.13.1)
└── plugman@0.20.2 (bplist-parser@0.0.5, nopt@1.0.10, dep-graph@1.1.0, rc@0.3.0, glob@3.2.9, request@2.22.0, npm@1.3.4)
MAC9s-Mac-mini:~ naveen$ cordova create /Users/naveen/Desktop/a com.example.hello HelloWorld
Creating a new cordova project with name "HelloWorld" and id "com.example.hello" at location "/Users/naveen/Desktop/a"
Downloading cordova library for www...
Download complete
MAC9s-Mac-mini:~ naveen$ cd a
-bash: cd: a: No such file or directory
MAC9s-Mac-mini:~ naveen$ cd Desktop/a
MAC9s-Mac-mini:a naveen$ ls
config.xml  merges      plugins
hooks       platforms   www
MAC9s-Mac-mini:a naveen$ cordova platform add ios
Downloading cordova library for ios...
Download complete
Creating ios project...
xcrun: Error: could not stat active Xcode path '/Applications/Xcode 2.app/Contents/Developer'. (No such file or directory)
Cordova can only run in Xcode version 4.6 or greater.
Error: /Users/naveen/.cordova/lib/ios/cordova/3.4.0/bin/create: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:112:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
MAC9s-Mac-mini:a naveen$ cordova platform add ios
Creating ios project...
xcrun: Error: could not stat active Xcode path '/Applications/Xcode 2.app/Contents/Developer'. (No such file or directory)
Cordova can only run in Xcode version 4.6 or greater.
Error: /Users/naveen/.cordova/lib/ios/cordova/3.4.0/bin/create: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:112:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)

2 个答案:

答案 0 :(得分:1)

Please Check did you follow below steps in same way:

a) Download and install Node.js
b)$ sudo npm install -g cordova
c)Set your path where you want to create your project in this case Desktop
   $ cd Desktop
d)$ cordova create Firstapp com.example.first FirstApp
e)$ cd Firstapp
f)$ cordova platform add ios
g)$ cordova platforms ls
h)$ cordova build
i) Now, you can add your plugins

1)$ cordova plugin add org.apache.cordova.device
2)$ cordova plugin add org.apache.cordova.network-information
3)$ cordova plugin add org.apache.cordova.battery-status 
and soon

Thanks

答案 1 :(得分:0)

你必须使用xcode-select来选择默认的xcode,否则你指的是错误的路径。试试这个:

sudo xcode-select -switch /path_to_xcode/Xcode.app

这篇文章也可能有所帮助(Aaron Brager的回答): xcrun: Error: could not stat active Xcode path

https://groups.google.com/forum/#!msg/phonegap/UxtHlw8kV4U/AbDmQV-2yPUJ