[SOLVED] Issue running ionic build on new install


#1

I’m trying to set up Ionic on a new machine. I’ve installed node (v5) and ionic@beta, plus tried cordova@latest.

This is the output when I try and run ionic build ios:

Running 'build:before' gulp task before build
[11:38:48] Starting 'clean'...
[11:38:49] Finished 'clean' after 22 ms
[11:38:49] Starting 'build'...
[11:38:49] Starting 'sass'...
[11:38:49] Starting 'html'...
[11:38:49] Starting 'fonts'...
[11:38:49] Starting 'scripts'...
[11:38:49] Finished 'scripts' after 62 ms
[11:38:49] Finished 'html' after 72 ms
[11:38:49] Finished 'fonts' after 84 ms
[11:38:50] Finished 'sass' after 1.3 s
[11:39:00] Finished 'build' after 11 s
[11:39:00] Starting 'build:before'...
[11:39:00] Finished 'build:before' after 7.73 μs

 Using this version of Cordova with older version of cordova-ios is being deprecated. Consider upgrading to cordova-ios@4.0.0 or newer.
Running command: /Users/James/Sites/app/hooks/after_prepare/010_add_platform_class.js /Users/James/Sites/app
add to body class: platform-ios
Running command: /Users/James/Sites/app/platforms/ios/cordova/build 
module.js:341
    throw err;
    ^

Error: Cannot find module 'cordova-common'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/James/Sites/app/platforms/ios/cordova/Api.js:25:20)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
Error: /Users/James/Sites/app/platforms/ios/cordova/build: Command failed with exit code 1

And ionic info:

Your system information:

Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.6 
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v5.11.1
Xcode version: Xcode 7.3.1 Build version 7D1014 

Can anyone point me in the right direction?


#2

Have you tried reinstalling cordova?
npm uninstall -g cordova
npm install -g cordova

Also, have you tried updating your cordova-ios package like the error/warning suggests?


#3

Installing cordova@latest will give you the latest master release, not the latest stable release. This is probably causing your errors.


#4

Thanks! I’ve uninstalled and reinstalled cordova (just cordova, not cordova-latest), but I’ve got the same error again.

Here’s my updated ionic info:

Cordova CLI: 6.1.1
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.6 
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v5.11.1
Xcode version: Xcode 7.3.1 Build version 7D1014

I’ve also tried running “npm update -g cordova-ios”, but that doesn’t output anything.


#5

I eventually resolved this by installing node 4 (instead of 5), reinstalling ionic@beta and cordova, removing the node_modules and packages folders and re-running npm install and ionic platform add ios. Thanks for your help @mhartington!