Error: Cannot find module 'xcode'
pjorquera opened this issue · 3 comments
pjorquera commented
This issue is fixed with Cordova version 8.1.2
Adding plugin to a project using Cordova CLI 8.1.x (8.1.0, 8.1.1) fails to install displaying the following error:
Installing "cordova-fabric-plugin" for ios
Failed to install 'cordova-fabric-plugin': Error: Cannot find module 'Xcode'
Steps to reproduce
- Create a simple Cordova project using CLI version 8.1.x:
$ cordova create myApp com.okode.myApp myApp
- Add platform iOS
$ cordova platform add ios
- Add cordova-fabric-plugin:
$ cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=myAPIKey --variable FABRIC_API_SECRET=myAPISecret
Output error:
Installing "cordova-fabric-plugin" for ios
Failed to install 'cordova-fabric-plugin': Error: Cannot find module 'xcode'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:77:12)
at Object.removeShellScriptBuildPhase (/Users/pjorquera/kk/myApp/plugins/cordova-fabric-plugin/hooks/lib/ios-helper.js:78:29)
at module.exports (/Users/pjorquera/kk/myApp/plugins/cordova-fabric-plugin/hooks/after_plugin_add.js:21:19)
at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:196:18)
at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:172:16)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:140:20
brotich commented
according to the cordava-lib changes, the Context.requireCordovaModule
is currently being considered for deprecation and eventually removed in the next major version of cordava-lib.
relevant quote:
I can see the logic.
Since the workaround is pretty straight forward (npm install ) this can be easily overcome with a deprecation message & documentation.
A clear message of library xyz is relying on package abc which is no longer provided by cordova. Run npm install abc yourself could do magic to cordova developers hours of work and sanity...
source: apache/cordova-lib#706 (comment)
recommendation: the plugin should install the xcode
npm package via npm install xcode
and use it directly in the ios helper scripts
SteaM92 commented
unfortunately I am having the same issue but npm install xcode doesn't work for me :/ any help on that?
pjorquera commented
Fixed with Cordova version 8.1.2