janpio opened a new issue #540: Cordova iOS 5.0.0 can not build without `node_modules` present because of missing `shelljs` for build phase script URL: https://github.com/apache/cordova-ios/issues/540 # Bug Report ## Problem ### What is expected to happen? The Cordova iOS project used to be able to build outside of a Cordova project. You could just copy `platforms/ios` and then use Xcode or `xcodebuild` to build your app. ### What does actually happen? You can not do that any more as the `shelljs` dependency is used by one of the build step scripts and is not present without the parent `node_modules`. ## Information As soon as `node_modules` from the main project folder is missing (because it was either not created after a checkout from git, or because you copied over the iOS project from `platforms/ios` to somewhere else, you get an error like this when trying to build with `xcodebuild` or Xcode: ``` MacBook-Pro:ios sujan$ xcodebuild -workspace HelloCordova.xcworkspace -scheme HelloCordova -configuration Debug -sdk iphonesimulator -destination platform="iOS Simulator,name=iPhone X" build CONFIGURATION_BUILD_DIR=/Users/sujan/Projects/throwaway/cordovaIos5Test2/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/Users/sujan/Projects/throwaway/cordovaIos5Test2/platforms/ios/build/sharedpch Build settings from command line: CONFIGURATION_BUILD_DIR = /Users/sujan/Projects/throwaway/cordovaIos5Test2/platforms/ios/build/emulator SDKROOT = iphonesimulator12.1 SHARED_PRECOMPS_DIR = /Users/sujan/Projects/throwaway/cordovaIos5Test2/platforms/ios/build/sharedpch note: Using new build system note: Planning build note: Constructing build description [...] PhaseScriptExecution Copy\ www\ directory /Users/sujan/Library/Developer/Xcode/DerivedData/HelloCordova-gnnlxcyurmjjpncmcbzgevousltv/Build/Intermediates.noindex/HelloCordova.build/Debug-iphonesimulator/HelloCordova.build/Script-304B58A110DAC018002A0835.sh (in target: HelloCordova) cd /Users/sujan/Projects/throwaway/cordovaIos5Test2/platforms/ios /bin/sh -c /Users/sujan/Library/Developer/Xcode/DerivedData/HelloCordova-gnnlxcyurmjjpncmcbzgevousltv/Build/Intermediates.noindex/HelloCordova.build/Debug-iphonesimulator/HelloCordova.build/Script-304B58A110DAC018002A0835.sh module.js:338 throw err; ^ Error: Cannot find module 'shelljs' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:286:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/Users/sujan/Projects/throwaway/cordovaIos5Test2/platforms/ios/cordova/lib/copy-www-build-step.js:34:13) at Module._compile (module.js:434:26) at Object.Module._extensions..js (module.js:452:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:475:10) Command PhaseScriptExecution failed with a nonzero exit code ** BUILD FAILED ** The following build commands failed: PhaseScriptExecution Copy\ www\ directory /Users/sujan/Library/Developer/Xcode/DerivedData/HelloCordova-gnnlxcyurmjjpncmcbzgevousltv/Build/Intermediates.noindex/HelloCordova.build/Debug-iphonesimulator/HelloCordova.build/Script-304B58A110DAC018002A0835.sh (1 failure) MacBook-Pro:ios sujan$ ``` (The error in Xcode directly is identical, as it just uses `xcodebuild` under the hood.) #### Known workaround You can work around this problem by running `npm install shelljs` in your iOS project. This currently seems to be the only dependency required during build. #### How could this be solved? Dependencies that are necessary for the scripts included in the project itself could/should be included in the actual project. (Alternatively there could be a package.json that is not installed by default, so it becomes at least possible to discover this when looking around) ### Command or Code ``` cordova create testProject cd testProject cordova platform add [email protected] cordova build ios # now copy the `xcodebuild` command (and add `"` around the `-destination platform=` parameter as this is missing from the command output) cd platforms/ios xcodebuild ... # command from before => works rm ../../node_modules xcodebuild ... # command from before => fails with error shown above ``` ### Environment, Platform, Device <!-- In what environment, on what platform or on which device are you experiencing the issue? --> macOS 10.14.2 (Mojave) ### Version information <!-- What are relevant versions you are using? For example: Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins Other Frameworks: Ionic Framework and CLI version Operating System, Android Studio, Xcode etc. --> Cordova CLI 8.1.1, Cordova iOS 5.0.0, Xcode 10.1 (10B61) ## Checklist <!-- Please check the boxes by putting an x in the [ ] like so: [x] --> - [x] I searched for existing GitHub issues - [x] I updated all Cordova tooling to most recent version - [x] I included all the necessary information above
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
