googlearchive / generator-angularfire

Yeoman generator for AngularFire: Angular + Firebase apps
191 stars 52 forks source link

SyntaxError: bower.json: Unexpected string #21

Closed tgvarik closed 9 years ago

tgvarik commented 9 years ago

Problem

The generator produces an invalid bower.json file when angular-router.js is not selected for inclusion.

Steps to Reproduce

$ npm install generator-angularfire
...
[Yeoman Doctor] Everything looks all right!
...
$ yo angularfire fooapp
...
? Firebase instance (https://<your instance>.firebaseio.com) fooapp
? Use FirebaseSimpleLogin? Yes
? Which providers shall I install? Email/Password
? Would you like to use Sass (with Compass)? Yes
? Would you like to include Bootstrap? Yes
? Would you like to use the Sass version of Bootstrap? Yes
? Which modules would you like to include? angular-animate.js, angular-cookies.js, angular-resource.js, angular-sanitize.js, angular-touch.js
...
I'm all done. Running bower install & npm install for you to install the required dependencies. If this fails, try running the command yourself.
...
bower                       EMALFORMED Failed to read /Users/tom/dev/fooapp/bower.json

Additional error details:
Unexpected string

undefined:14
    "firebase-simple-login": "1.6.x",
    ^
SyntaxError: Unexpected string
    at Object.parse (native)
    at Generator._injectDependencies (/Users/tom/dev/fooapp/node_modules/generator-angularfire/app/index.js:465:23)
    at /Users/tom/dev/fooapp/node_modules/generator-angularfire/node_modules/yeoman-generator/node_modules/async/lib/async.js:232:13
    at /Users/tom/dev/fooapp/node_modules/generator-angularfire/node_modules/yeoman-generator/node_modules/async/lib/async.js:113:21
    at /Users/tom/dev/fooapp/node_modules/generator-angularfire/node_modules/yeoman-generator/node_modules/async/lib/async.js:24:16
    at /Users/tom/dev/fooapp/node_modules/generator-angularfire/node_modules/yeoman-generator/node_modules/async/lib/async.js:229:17
    at /Users/tom/dev/fooapp/node_modules/generator-angularfire/node_modules/yeoman-generator/node_modules/async/lib/async.js:516:34
    at Generator.<anonymous> (/Users/tom/dev/fooapp/node_modules/generator-angularfire/node_modules/yeoman-generator/lib/actions/install.js:43:7)
    at ChildProcess.emit (events.js:117:20)
    at Process.ChildProcess._handle.onexit (child_process.js:810:12)

Workaround

Inspecting the generated bower.json file reveals it is missing a comma:

{
  "name": "fooapp",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.16",
    "json3": "~3.3.1",
    "es5-shim": "~3.1.0",
    "bootstrap-sass-official": "~3.2.0",
    "angular-resource": "1.2.16",
    "angular-cookies": "1.2.16",
    "angular-sanitize": "1.2.16",
    "angular-animate": "1.2.16",
    "angular-touch": "1.2.16"                   <-- missing comma
    "firebase-simple-login": "1.6.x",
    "angularfire": "0.8.x"
  },
  "devDependencies": {
    "angular-mocks": "1.2.16",
    "angular-scenario": "1.2.16",
    "mockfirebase": "0.2.x"
  },
  "appPath": "app"
}

Adding the missing comma fixes the file.