I am trapped in a somewhat infinite loop of struggles! Please help xD
No matter what phonegap or cordova cli commands I run, cordova seems to delete the very files it's looking for previous to looking for them.
Here are just a few known commands which trigger the error for me:
$ cordova plugin add <plugin name>
$ phonegap plugin add <plugin name>
$ cordova platform update <platform name>
$ phonegap platform update <platform name>
$ cordova platform remove <platform name>
$ phonegap platform remove <platform name>
See below terminal output which shows the output I get when running these commands. I am really unsure why cordova is deleting the very file it's trying to rename before it tries to rename it. Very frustrating!
Step 1 (check to ensure we have a clean git head and no changes in our working set)
apple@Child-2:~/projects/infiniteinternet/prodmode/prodmode-client-mobile-builds/phonegap * feature-barcode-scanner$ git status
# On branch feature-barcode-scanner
nothing to commit, working directory clean
Step 2 (attempt plugin add)
apple@Child-2:~/projects/infiniteinternet/prodmode/prodmode-client-mobile-builds/phonegap * feature-barcode-scanner$ cordova plugin add phonegap-plugin-barcodescanner --variable CAMERA_USAGE_DESCRIPTION="To scan barcodes"
Unmet project requirements for latest version of phonegap-plugin-barcodescanner:
cordova-android (6.2.3 in project, >=6.3.0 required)
Fetching highest version of phonegap-plugin-barcodescanner that this project supports: 6.0.8 (latest is 7.0.0)
Error: Failed to fetch plugin phonegap-plugin-barcodescanner@6.0.8 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 254 Error output:
npm WARN cordova-plugin-file-transfer@1.5.1 requires a peer of cordova-plugin-file@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN cordova-plugin-media-capture@1.2.0 requires a peer of cordova-plugin-file@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN com.prodmod.mobileclient@1.0.0 No repository field.
npm WARN com.prodmod.mobileclient@1.0.0 No license field.
npm ERR! path prodmode-client-mobile-builds/phonegap/node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'prodmode-client-mobile-builds/phonegap/node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js' -> 'prodmode-client-mobile-builds/phonegap/node_modules/cordova-ios/node_modules/simple-plist/node_modules/.base64-js.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
┌──────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /Users/apple/.config │
└──────────────────────────────────────────────────────────┘
npm ERR! A complete log of this run can be found in:
npm ERR! .npm/_logs/2017-11-10T00_23_21_467Z-debug.log
Step 3 (check git changes caused by the command in step 2)
Okay, so it failed. Let's find out what happened to the supposed missing file. Well, apparently cordova deleted the file before it looked for it?
apple@Child-2:~/projects/infiniteinternet/prodmode/prodmode-client-mobile-builds/phonegap * feature-barcode-scanner$ git status
# On branch feature-barcode-scanner
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/.npmignore
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/.travis.yml
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/LICENSE.MIT
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/README.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/base64js.min.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/bower.json
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/lib/b64.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/package.json
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/test/big-data.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/test/convert.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/base64-js/test/url-safe.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/.jshintrc
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/.travis.yml
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/History.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/LICENSE
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/Makefile
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/README.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/dist/plist-build.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/dist/plist-parse.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/dist/plist.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/examples/browser/index.html
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/index.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/lib/build.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/lib/parse.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/plist/package.json
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/.npmignore
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/CHANGELOG.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/LICENSE
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/README.md
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/Utility.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLAttribute.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLCData.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLComment.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDAttList.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDElement.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDEntity.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDTDNotation.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDeclaration.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDocType.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDocument.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLDocumentCB.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLElement.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLNode.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLRaw.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLStreamWriter.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLStringWriter.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLStringifier.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLText.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/XMLWriterBase.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/lib/index.js
# deleted: node_modules/cordova-ios/node_modules/simple-plist/node_modules/xmlbuilder/package.json
#
no changes added to commit (use "git add" and/or "git commit -a")
If anyone has any suggestions on how to fix this issue, I'd be super grateful. I'm not sure what caused it or when it took effect, but it's been a couple weeks now that I haven't been able to add plugins to my project.
Thanks in advance!
EDIT: Environment settings:
apple@Child-2:/ $ cordova --version
7.0.1
┌──────────────────────────────────────────┐
│ Update available: 7.1.0 (current: 7.0.1) │
│ Run npm install -g cordova to update. │
└──────────────────────────────────────────┘
apple@Child-2:/ $ phonegap --version
7.1.1
apple@Child-2:/ $ node --version
v6.11.1
apple@Child-2:/ $ npm --version
5.4.2
Hrmm, so I was able to fix this issue. The discussion in the thread was helpful in leading me to the correct answer without actually solving it.
Here's what I did:
Step one: Update cordova
$ sudo npm install -g cordova
Phonegap was already updated to the latest version but my cordova wasn't.
Step two: Update node and npm
Apparently, after updating these 2 components everything in my app played nice again. At this point it would install into /plugins
using phonegap plugin add <plugin name>
but it wasn't propagating the plugin code to Android until I switched the location of the Maven repository.
Step three: Update Maven repository location in build.gradle
It's not really related to my question but I was able to build the apk permissions as soon as I changed the Maven repository location in <app root>/phonegap/platforms/android/build.gradle
Here's what I changed in build.gradle...
My original build.gradle settings:
buildscript {
repositories {
mavenCentral()
jcenter()
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
mavenCentral()
jcenter()
}
}
Which I changed to:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
After that I was able to build my APK with the correct plugin permissions and use the plugin I added.