如何通过CLI将iOS插件添加到Phonegap?

时间:2018-03-02 12:00:55

标签: cordova phonegap phonegap-cli

我正在尝试使用 Phonegap CLI 构建我的应用。我已经创建了项目,然后当我尝试添加插件时,我得到了:

  

$ sudo phonegap plugin add cordova-plugin-globalization

     

错误:无法获取插件   git + https://github.com/apache/cordova-plugin-globalization.git来自   注册表中。

     

这可能是连接问题,也可能是插件规范   不正确。

     

检查您的连接和插件名称/版本/网址。

     

错误:npm:命令失败,退出代码为1错误输出:

     

npm ERR!代码1

     

npm ERR!命令失败:/ usr / bin / git clone -q   https://github.com/apache/cordova-plugin-globalization.git   /Users/apple/.npm/_cacache/tmp/git-clone-4dc164cf

     

npm ERR! /Users/apple/.npm/_cacache/tmp/git-clone-4dc164cf/.git:   许可被拒绝

     

npm ERR!

     

npm ERR!可以在以下位置找到此运行的完整日志:

     

npm ERR!
  /Users/apple/.npm/_logs/2018-03-02T11_53_27_023Z-debug.log

完整的日志中包含:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   'git+https://github.com/apache/cordova-plugin-globalization.git',
1 verbose cli   '--production',
1 verbose cli   '--save' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose npm-session 85b442bcb6c2c486
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for git+https://github.com/apache/cordova-plugin-globalization.git Command failed: $
7 silly fetchPackageMetaData /Users/apple/.npm/_cacache/tmp/git-clone-4dc164cf/.git: Permission denied
8 verbose stack Error: Command failed: /usr/bin/git clone -q https://github.com/apache/cordova-plugin-globalization.gi$
8 verbose stack /Users/apple/.npm/_cacache/tmp/git-clone-4dc164cf/.git: Permission denied
8 verbose stack
8 verbose stack     at ChildProcess.exithandler (child_process.js:275:12)
8 verbose stack     at emitTwo (events.js:126:13)
8 verbose stack     at ChildProcess.emit (events.js:214:7)
8 verbose stack     at maybeClose (internal/child_process.js:925:16)

8 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

9 verbose cwd /Users/apple/Desktop/chambes phonegap app/Chamresdhotesapp

10 verbose Darwin 17.4.0

11 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "git+https://github.com/apache/cordova-plugin-glo$
12 verbose node v8.9.4
13 verbose npm  v5.6.0
14 error code 1
15 error Command failed: /usr/bin/git clone -q https://github.com/apache/cordova-plugin-globalization.git /Users/apple$
15 error /Users/apple/.npm/_cacache/tmp/git-clone-4dc164cf/.git: Permission denied
16 verbose exit [ 1, true ]

如果我浏览 / Users / apple / ,我就会看不到 .npm 文件夹。这是隐藏的吗?

1 个答案:

答案 0 :(得分:0)

Eugh,我在踢自己!!!!

  • 我的项目文件夹名为" chambres new test"。它似乎并不喜欢这些空间。我已将其重新创建为" chambres",现在又添加了插件
  • 我试图像这样添加插件:

sudo phonegap plugin add https://github.com/apache/cordova-plugin-device.git

出于某种原因,它并不是那样的。但它确实有用:

sudo phonegap plugin add cordova-plugin-device