Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'toString' of null #45

Open
g1un opened this issue Nov 30, 2016 · 3 comments
Open

TypeError: Cannot read property 'toString' of null #45

g1un opened this issue Nov 30, 2016 · 3 comments

Comments

@g1un
Copy link

g1un commented Nov 30, 2016

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

@bebo-dot-dev
Copy link

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 $ 

@bebo-dot-dev
Copy link

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

@g1un
Copy link
Author

g1un commented Dec 3, 2016

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'],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants