generator-ionic
generator-ionic copied to clipboard
yo ionic throws an error
Everytime I run "yo ionic", it keeps failing. I've updated node and npm and reinstalled yo and grunt and bower, but still get the error below:
Installing selected Cordova plugins, please wait. Installing starter template. Please wait
info ... Fetching https://github.com/driftyco/ionic-starter-sidemenu/archive/master.tar.gz ...
info This might take a few moments
npm http GET http://registry.cordova.io/org.apache.cordova.device ...............npm http 200 http://registry.cordova.io/org.apache.cordova.device npm http GET http://cordova.iriscouch.com/registry/_design/app/_rewrite/org.apache.cordova.device/-/org.apache.cordova.device-0.3.0.tgz
✔ Done in /Users/sineo/.cache/yeoman/driftyco/ionic-starter-sidemenu/master
/usr/local/lib/node_modules/generator-ionic/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/lockfile/lockfile.js:46 throw er ^ TypeError: undefined is not a function at readIndex (/usr/local/lib/node_modules/generator-ionic/app/index.js:185:29) at /usr/local/lib/node_modules/generator-ionic/node_modules/yeoman-generator/lib/base.js:428:16 at processImmediate as _immediateCallback
@sineo Same issue here.
The function this.engine
is not defined. I ran into this while trying to update the version of some dependencies (like angular 1.4, cordova 5.1 and ionic 1.0.0)...
After digging around some, I've discovered that yeoman-generator 0.20.* does not work, but version 0.19.2 does. This is the culprit, as best I can tell:
https://github.com/yeoman/generator/commit/c094740fb8d9d18f1a9dcc1f2a78e153f0f9bb18#diff-661285f2c7d866fb08559eb1e5748a7f
See also the comments below that commit...
Anyway, the line 185 in generator-ionic/app/index.js which calls the now missing engine
templating function wants to read an index.html
file depending on which starter setup (sidebar, tabs, blank) you chose. This is an external resource from the guys at driftyco, so it seems unlikely there's any real templating to be done there?
Long story short: the following replacement of line 185 makes things work for me with the latest yeoman-generator, 0.20.1.
// this.indexFile = this.engine(this.read(path.join(this.starterCache, 'index.html')), this);
this.indexFile = this.fs.read(path.join(this.starterCache, 'index.html'));