bower: .bower.json contains illegal json (sometimes)

installing package with bower i get 2 bower.json files: bower.json and .bower.json.

the .bower.json file contains:

{
  "name": "jquery.serialscroll",
  "version": "1.3.1",
  "description": "Animated scrolling of series with jQuery",
  "homepage": "https://github.com/flesler/jquery.serialScroll",
  "main": [
    "./jquery.serialScroll.js",
    "./jquery.serialScroll.min.js"
  ],
  "dependencies": {
    "jquery": ">=1.8",
    "jquery.scrollTo": ">=2.1.0"
  },
  "keywords": [
    "slideshow",
    "sequence",
    "animated",
    "animation",
    "scrolling",
    "scroll",
    "prev",
    "next"
  ],
  "author": {
    "name": "Ariel Flesler",
    "web": "http://flesler.blogspot.com/"
  },
  "_release": "1.3.1",
  "_resolution": {
    "type": "version",
    "tag": "1.3.1",
    "commit": "eb3c573bee7f0fa60c46c31822f03c2479eb6b6e"
  },
  "_source": "git://github.com/flesler/jquery.serialScroll.git",
  "_target": "*",
  "_originalSource": "jquery.serialScroll"
}ll"
}

done with command install bower

and in json file:

"ignore": [
 "**/.*",
    "node_modules",
    "bower_components"
  ],
  "dependencies": {
    "bootstrap": ">=3.3.5",
    "bootstrap-touchspin": "~3.0.3",
    "font-awesome": "~4.4.0",
    "javascript-equal-height-responsive-rows": "*",
    "jquery": ">=2.1.4",
    "jquery.scrollTo": "~2.1.2",
    "jquery.serialscroll": "jquery.serialScroll#~1.3.1",
    "jquery-mousewheel": "~3.1.13",
    "jquery-parallax": "~1.1.3",
    "jquery-ui": "~1.11.4",
    "malihu-custom-scrollbar-plugin": "~3.1.3",
    "minimalect": "*",
    "moment": "~2.10.6",
    "imagesloaded": "~3.2.0"
  },
  "resolutions": {
    "jquery.scrollTo": "~2.1.2",
    "jquery": ">=1.9.0"
  }

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Here’s a super reduced test-case:

  1. bower cache clean
  2. bower install the following:
{
  "name": "px",
  "version": "0.0.1",
  "dependencies": {
    "jquery": "~2.1.4",
    "angular-ts-select2": "~1.0.0"
  }
}

If you follow the installation of jquery and jQuery through the output below, you notice that the right jquery is installed first, after which bower resolves the dependency (jQuery) that is listed in angular-ts-select2. They are also installed in that order.

bower install
bower not-cached    git://github.com/jquery/jquery-dist.git#~2.1.4
bower resolve       git://github.com/jquery/jquery-dist.git#~2.1.4
bower not-cached    git://github.com/tscheinecker/angular-ts-select2.git#~1.0.0
bower resolve       git://github.com/tscheinecker/angular-ts-select2.git#~1.0.0
bower download      https://github.com/tscheinecker/angular-ts-select2/archive/v1.0.0-alpha.20150603.1.tar.gz
bower download      https://github.com/jquery/jquery-dist/archive/2.1.4.tar.gz
bower extract       angular-ts-select2#~1.0.0 archive.tar.gz
bower resolved      git://github.com/tscheinecker/angular-ts-select2.git#1.0.0-alpha.20150603.1
bower not-cached    git://github.com/ivaynberg/select2.git#~4.0.0
bower resolve       git://github.com/ivaynberg/select2.git#~4.0.0
bower not-cached    git://github.com/jquery/jquery.git#~2.1.4
bower resolve       git://github.com/jquery/jquery.git#~2.1.4
bower not-cached    git://github.com/angular/bower-angular.git#1.2 - 1.4
bower resolve       git://github.com/angular/bower-angular.git#1.2 - 1.4
bower extract       jquery#~2.1.4 archive.tar.gz
bower resolved      git://github.com/jquery/jquery-dist.git#2.1.4
bower download      https://github.com/ivaynberg/select2/archive/4.0.1.tar.gz
bower download      https://github.com/angular/bower-angular/archive/v1.4.8.tar.gz
bower download      https://github.com/jquery/jquery/archive/2.1.4.tar.gz
bower extract       angular#1.2 - 1.4 archive.tar.gz
bower resolved      git://github.com/angular/bower-angular.git#1.4.8
bower extract       select2#~4.0.0 archive.tar.gz
bower extract       jQuery#~2.1.4 archive.tar.gz
bower resolved      git://github.com/jquery/jquery.git#2.1.4
bower invalid-meta  select2 is missing "ignore" entry in bower.json
bower resolved      git://github.com/ivaynberg/select2.git#4.0.1
bower install       angular-ts-select2#1.0.0-alpha.20150603.1
bower install       jquery#2.1.4
bower install       angular#1.4.8
bower install       jQuery#2.1.4
bower install       select2#4.0.1
bower error         Unexpected string

Stack trace:
SyntaxError: Unexpected string
    at Object.parse (native)
    at /usr/local/lib/node_modules/bower/lib/core/Manager.js:208:37
    at _fulfilled (/usr/local/lib/node_modules/bower/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/bower/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/node_modules/q/q.js:796:13)
    at /usr/local/lib/node_modules/bower/node_modules/q/q.js:604:44
    at runSingle (/usr/local/lib/node_modules/bower/node_modules/q/q.js:137:13)
    at flush (/usr/local/lib/node_modules/bower/node_modules/q/q.js:125:13)
    at nextTickCallbackWith0Args (node.js:433:9)
    at process._tickCallback (node.js:362:13)

Console trace:
Error
    at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:83:37)
    at Logger.<anonymous> (/usr/local/lib/node_modules/bower/bin/bower:116:30)
    at emitOne (events.js:78:13)
    at Logger.emit (events.js:170:7)
    at Logger.emit (/usr/local/lib/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
    at /usr/local/lib/node_modules/bower/lib/commands/index.js:48:20
    at _rejected (/usr/local/lib/node_modules/bower/node_modules/q/q.js:844:24)
    at /usr/local/lib/node_modules/bower/node_modules/q/q.js:870:30
    at Promise.when (/usr/local/lib/node_modules/bower/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/node_modules/q/q.js:788:41)
System info:
Bower version: 1.7.2
Node version: 5.2.0
OS: Darwin 14.5.0 x64

We also see that jQuery does not resolve to the jquery-dist repo, which actually contains the bower.json but simply to jquery/jquery, where no bower.json is present. Even though I’d love to just point the jQuery package to the right source in the Bower registry, I think we should try to find out what exactly is causing the invalid .bower.json (below) first:

...
   "_source": "git://github.com/jquery/jquery.git",
   "_target": "~2.1.4"
 }"~2.1.4"
}

Update

So if you bower install the following:

{
  "name": "test",
  "version": "1.0.0",
  "ignore": [
 "**/.*",
    "node_modules",
    "bower_components"
  ],
  "dependencies": {
    "jquery": ">=2.1.4",
    "jQuery": ">=2.1.4"
  }
}

I am getting the same error and the .bower.json looks a lot worse (see below). That leads me to believe that Bower is fetching the dependencies and (kind of simultaneously) writing to the same .bower.json. This kind of makes sense, because it is installing the dependencies into the same directory. Considering the original issue can be replicated by running bower install twice, I wonder if this happens everytime multiple dependencies depend on the same package. The first bower.json reported in this issue also has no dependencies that require jQuery, so it not related to that alone!

bad .bower.json:    

{
  "name": "jQuery",
  "homepage": "https://github.com/jquery/jquery",
  "version": "2.2.0",
  "_release": "2.2.0",
  "_resolution": {
    "type": "version",
    "tag": "2.2.0",
    "commit": "33b548c8e3d43b2ebdfb129fd8086a3b0c905919"
  },
  "_source": "git://github.com/jquery/jquery.git",
  "_target": ">=2.1.4"
}pe": "version",
    "tag": "2.2.0",
    "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5"
  },
  "_source": "git://github.com/jquery/jquery-dist.git",
  "_target": ">=2.1.4"
}

By the looks of the responses, you should check if your dependencies have capitals and remove them!

Im closing my issue, no longer had this problem and bower popularity seems in decline, since webpack2 and browserify makes separation no longer needed.

If you manually copy the full module from a separate install into your web env, your build process should skip trying to download the bad module via bower. That’s what we did.

On Tue, Mar 8, 2016 at 12:40 AM, Dan Caragea notifications@github.com wrote:

Any news on this? Or workaround/patch? Currently I simply cannot init my project…😦

— Reply to this email directly or view it on GitHub https://github.com/bower/bower/issues/2067#issuecomment-193664324.

|<ipp McMichael Senior Front End Software Engineer kmcmichael@twistbioscience.com

Any news on this? Or workaround/patch? Currently I simply cannot init my project…😦