question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'split' of undefined

See original GitHub issue

I get this error when using csvtojson. My node version is v7.10.0.

Converter.js:85 Uncaught TypeError: Cannot read property 'split' of undefined
    at Object.<anonymous> (Converter.js:85)
    at Object.module.exports (Converter.js:542)
    at __webpack_require__ (bootstrap 6e0e07b…:659)
    at fn (bootstrap 6e0e07b…:85)
    at Object.<anonymous> (index.js:2)
    at __webpack_require__ (bootstrap 6e0e07b…:659)
    at fn (bootstrap 6e0e07b…:85)
    at Object.<anonymous> (csv2json.js:2)
    at __webpack_require__ (bootstrap 6e0e07b…:659)
    at fn (bootstrap 6e0e07b…:85)

When I import csvtojson, this error occur.

import CSV from 'csvtojson';

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JoseExpositocommented, Jul 6, 2017

Same. It happens because Converter.js is using process.versions.node here:

https://github.com/Keyang/node-csvtojson/blob/46f97473b6ab68d40f82e5217668beab51b4e183/libs/core/Converter.js#L85

Which is not available using a bundler like webpack (in my case) in the frontend. @Keyang, this can by fixed by checking if the function is available dynamically:

function bufFromString(str){
    return (typeof Buffer. from == 'function')
        ? Buffer.from(str,"utf8")
        : new Buffer(str,"utf8")
}

You can quickly check the behaviour:

$ node --version
v7.6.0
$ node
> (typeof Buffer. from == 'function')
true

@Kaylang, should I create a pull request?

@takanorip You can downgrade csvtojson in your package.json to 1.1.5 to get it working for the moment:

"csvtojson": "1.1.5",
0reactions
JoseExpositocommented, Oct 3, 2017

It looks like the change is already available in 1.1.8, please update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent cannot read property split of undefined
This error is a TypeError , and it occurs when calling a method, operand, or argument on the wrong data type, or when...
Read more >
How to Prevent cannot read property split of ... - Gopi Gorantala
The "cannot read property 'split' of undefined" error occurs when trying to call split() method on a variable that stores an undefined value....
Read more >
Cannot Read Property 'split' of Undefined - freeCodeCamp
it will throw the TypeError: Cannot read property 'split' of undefined error. The split method. When split is called on a string, it...
Read more >
Uncaught TypeError: Cannot read property 'split' of undefined
Your question answers itself ;) If og_date contains the date, it's probably a string, so og_date.value is undefined.
Read more >
TypeError: Cannot read property 'split' of undefined - JavaScript
So the argument word is coming in as undefined and therefore you can't run split() on it. You can either make sure it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found