bradstewart / electron-boilerplate-vue

Boilerplate application for Electron runtime
725 stars 94 forks source link

TypeError: data.trim is not a function #27

Closed lazytyper closed 8 years ago

lazytyper commented 8 years ago

Actually, I've updated node to v6.2.1. I'm not sure if this is the reason, but I'm getting this error when I try npm start:

TypeError: data.trim is not a function
    at format (/home/egon/dev/electron-vue/build/dev-runner.js:16:10)
    at Socket.<anonymous> (/home/egon/dev/electron-vue/build/dev-runner.js:30:17)
    at emitOne (events.js:101:20)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at Pipe.onread (net.js:542:20)

With this quickfix in build/dev-runner.js I got it to work:

function format (command, data, color) {
  // data seems to be a buffer and not a string
  if (typeof data !== 'string') {
    data = data.toString();
  }
  return color + command + END +
    '  ' + // Two space offset
    data.trim().replace(/\n/g, '\n' + repeat(' ', command.length + 2)) +
    '\n'
}
davejm commented 8 years ago

Had same problem. @eschmid72's solution worked for me.

djekl commented 8 years ago

Yeah, this only seems to be an issue on Windows. But the fix looks to have worked also

djekl commented 8 years ago

Ahh ok, I apologise. I assumed that Linux would work with it working fine for me in OSX, and only having this issue on Windows.

davejm commented 8 years ago

My comment went. Original comment was "I am on Linix".

davejm commented 8 years ago

Hmm weird

djekl commented 8 years ago

What version of Node and NPM do you have?

Here is mine

 ✝ ~  node -v
v5.11.1
 ✝ ~  npm -v
3.5.2
davejm commented 8 years ago

I'm at work atm so can't give exact versions but I know I have Node V6 and NPM V3. Pretty sure the problem occurs at Node V6

djekl commented 8 years ago

Ahh, ok. Let me check my version on Windows. I know that many things have problems in Node v6, thats why I run v5 on all my systems.

djekl commented 8 years ago

Yeah, v6 on Windows. Will install v5 now, and revert the change I made. See if I still have the same issue.

Edit: Looking at the site, v4 is LTS and v6 is the latest. So could be that. We will see...

djekl commented 8 years ago

Just to confirm, this looks to be an issue with Node v6. Should merge OK as works fine in Node v4 - v5

seegwen commented 8 years ago

I can confirm this bug.

el capitan 10.11.5 fresh install

$ node -v
v6.2.2
$ npm -v
3.9.5

@eschmid72's change did indeed fix the issue.

bradstewart commented 8 years ago

Merged https://github.com/bradstewart/electron-boilerplate-vue/pull/33 which resolves this issue.