bower-npm-resolver
bower-npm-resolver copied to clipboard
bower error Unexpected string in JSON at position N
I installed bower-npm-resolver because Chart.js stopped supporting Bower.
Following instructions from Chart.js I added the following to .bowerrc:
{
"resolvers": [
"bower-npm-resolver"
]
}
And ran:
npm install -g bower-npm-resolver
bower install npm:chart.js --save
Which added the following to bower.json:
"chart.js": "npm:chart.js#^2.2.1",
And now I get an error, which goes away if I remove the above line. When I run "bower install" I now see:
bower error Unexpected string in JSON at position 320
Stack trace:
SyntaxError: Unexpected string in JSON at position 320
at Object.parse (native)
at C:\Users\William Warby\AppData\Roaming\npm\node_modules\bower\lib\core\Ma
nager.js:209:37
at _fulfilled (C:\Users\William Warby\AppData\Roaming\npm\node_modules\bower
\lib\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\William Warby\AppData\Roaming\npm\nod
e_modules\bower\lib\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\William Warby\AppData\Roaming\n
pm\node_modules\bower\lib\node_modules\q\q.js:796:13)
at C:\Users\William Warby\AppData\Roaming\npm\node_modules\bower\lib\node_mo
dules\q\q.js:604:44
at runSingle (C:\Users\William Warby\AppData\Roaming\npm\node_modules\bower\
lib\node_modules\q\q.js:137:13)
at flush (C:\Users\William Warby\AppData\Roaming\npm\node_modules\bower\lib\
node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
It does seem to actually install all my Bower packages anyway, but obviously I'd prefer it to do so without the error. I'm using Node.js 6.2.0, Bower version 1.7.9.
I just tried it the other way using:
"npm+chart.js": "*",
This results in a different error:
bower E404 Registry returned 404 for GET on http://registry.npmjs.org/hca-ims-web
hca-ims-web is the name in my bower.json file. It's a private application, so not published on the NPM registry. Here is my bower.json file:
{
"name": "hca-ims-web",
...
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
...
"npm+chart.js": "*",
...
}
}
I had the same thing, seems to be something with the version number which somehow creates a malformed .bower.json. I solved this by stepping one version (of chart.js) back:
"chart.js": "npm:chart.js#2.2.0",