gulp-inline
gulp-inline copied to clipboard
TypeError: Cannot read property 'toString' of null
Sometimes have this error.
D:\test\amrest-app\node_modules\gulp-inline\index.js:50
el.attr('src', 'data:image/unknown;base64,' + contents.toString('base64'))
^
TypeError: Cannot read property 'toString' of null
at typeMap.img.template (D:\test\amrest-app\node_modules\gulp-inline\index.js:50:61)
at Transform._transform (D:\test\amrest-app\node_modules\gulp-inline\index.js:211:20)
at Transform._read (D:\test\amrest-app\node_modules\gulp-inline\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:184:10)
at Transform._write (D:\test\amrest-app\node_modules\gulp-inline\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:172:12)
at doWrite (D:\test\amrest-app\node_modules\gulp-inline\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:237:10)
at writeOrBuffer (D:\test\amrest-app\node_modules\gulp-inline\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:227:5)
at Transform.Writable.write (D:\test\amrest-app\node_modules\gulp-inline\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:194:11)
at write (D:\test\amrest-app\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:623:24)
at flow (D:\test\amrest-app\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (D:\test\amrest-app\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:664:5)
Fixed only after several remove/install node_modules, rebootings. My gulpfile.js: https://github.com/g1un/amrest-app/blob/master/gulpfile.js
Exactly the same problem started to appear here out of nowhere. I'm running on linux mint:
joe@joes-HP-EliteBook-8470p ~/eclipseWorkspace/iD8266 $ gulp
[07:37:51] Using gulpfile ~/eclipseWorkspace/iD8266/gulpfile.js
[07:37:51] Starting 'clean'...
[07:37:51] Starting 'files'...
[07:37:51] Starting 'inline'...
[07:37:51] Finished 'clean' after 89 ms
[07:37:54] Finished 'files' after 3.57 s
/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/index.js:50
el.attr('src', 'data:image/unknown;base64,' + contents.toString('base64'))
^
TypeError: Cannot read property 'toString' of null
at template (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/index.js:50:61)
at Transform._transform (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/index.js:202:20)
at Transform._read (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at Transform._write (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at Transform.Writable.write (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at write (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at Transform.pipeOnReadable (/home/joe/eclipseWorkspace/iD8266/node_modules/gulp-inline/node_modules/readable-stream/lib/_stream_readable.js:664:5)
joe@joes-HP-EliteBook-8470p ~/eclipseWorkspace/iD8266 $
Fixed. Looking at https://github.com/ashaffer/gulp-inline/blob/master/index.js#L50 gave me a clue where it was going wrong. This line of code exists to inline img tags and it doesn't like img tags that don't have a src attribute..in short, I broke this by way of my own broken invalid html markup.
Fixed by changing:
<img id="totpQrCode" alt="totpQrCode" class="form-control totpQrCode" />
to
<img id="totpQrCode" alt="totpQrCode" class="form-control totpQrCode" src="#" />
..in one of my html docs
In my case this problem begins with img with no src, but doesn't fix after adding this attribute, as if something has been broken in plugin after first wrong start. It takes place both on ubuntu 14.04 and windows 7. I've found acceptable decision for this project. I've added 'img' to disabledtypes, so now this bug doesn't appear any more. disabledTypes: ['js', 'css', 'img'],