Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EMALFORMED error when trying to register bower.json file

Tags:

node.js

bower

I'm having trouble registering my bower.json file at Bower. Any help would be greatly appreciated.

When I try to register my project at Bower using

bower register jsnlog git://github.com/mperdeck/jsnlog.js.git -V

I get the error message:

bower jsnlog#*              EMALFORMED Failed to read C:\Users\mperdeck\AppData\Local\Temp\mperdeck-PC-mperdeck\bower\js
nlog-6944-x00dtF\bower.json

Additional error details:
Unexpected token ?

The contents of my bower.json is simply (I got rid of spaces and newlines in an attempt to solve the problem):

{"name":"jsnlog.js","main":"jsnlog.js","version":"2.4.3"}

(note that there are no ? in that file)

And here are the details that appear on the screen when I run bower register:

PS D:\dev\jsnlog\jsnlog.js> bower register jsnlog git://github.com/mperdeck/jsnlog.js.git -V
bower jsnlog#*                 resolve git://github.com/mperdeck/jsnlog.js.git#*
bower jsnlog#*                download https://github.com/mperdeck/jsnlog.js/archive/2.4.3.tar.gz
bower jsnlog#*                 extract archive.tar.gz
bower jsnlog#*              EMALFORMED Failed to read C:\Users\mperdeck\AppData\Local\Temp\mperdeck-PC-mperdeck\bower\js
nlog-6944-x00dtF\bower.json

Additional error details:
Unexpected token ?

Stack trace:
SyntaxError: Unexpected token ?
    at Object.parse (native)
    at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\bower-json\lib\json.js:41:29
    at fs.js:266:14
    at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\graceful-fs\graceful-fs.js:105:5
    at Object.oncomplete (fs.js:107:15)

Console trace:
Trace
    at StandardRenderer.error (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\lib\renderers\StandardRenderer.j
s:74:17)
    at Logger.updateNotifier.packageName (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\bin\bower:109:18)
    at Logger.EventEmitter.emit (events.js:95:17)
    at Logger.emit (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\bower-logger\lib\Logger.js:29:
39)
    at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\lib\commands\register.js:86:20
    at _rejected (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:808:24)
    at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:834:30
    at Promise.when (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:1079:31)
    at Promise.promise.promiseDispatch (C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:752
:41)
    at C:\Users\mperdeck\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:574:44

System info:
Bower version: 1.2.8
Node version: 0.10.26
OS: Windows_NT 6.1.7601 x64
like image 449
user1147862 Avatar asked Mar 04 '14 10:03

user1147862


3 Answers

Your bower json file (as visible here: https://raw.github.com/mperdeck/jsnlog.js/2.4.3/bower.json) contains a leading invisible unicode character (likely a BOM).

This is visible in curl output: curl https://raw.github.com/mperdeck/jsnlog.js/2.4.3/bower.json

Start your bower.json file over from scratch, and use an editor that doesn't add crap :-).

like image 191
Mangled Deutz Avatar answered Nov 15 '22 23:11

Mangled Deutz


The problem was caused by the encoding of my bower.json file. However, removing the BOM wasn't enough - UTF8 (without BOM) was accepted. Instead, I had to use ASCII encoding.

like image 34
user1147862 Avatar answered Nov 16 '22 00:11

user1147862


I fixed this problem by opening the file with vim and saving with no bomb.

:setlocal nobomb 
:w 
like image 33
Matt Carrier Avatar answered Nov 15 '22 23:11

Matt Carrier