jeremyfa / yaml.js

Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: value.split is not a function

lewisakura opened this issue · comments

TypeError: value.split is not a function
    at Parser.cleanup (<path>\node_modules\yamljs\lib\Parser.js:534:21)
    at Parser.parse (<path>\yamljs\lib\Parser.js:67:23)
    at Yaml.parse (<path>\node_modules\yamljs\lib\Yaml.js:20:25)
    at fs.readdirSync.forEach.file (<file>:50:19)
    at Array.forEach (native)
    at Object.<anonymous> (<file>:38:28)
    at Object.<anonymous> (<file>:64:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at fs.readFile (<file>:39:4)
    at tryToString (fs.js:426:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:413:12)

yamljs fails to parse my YAML file, of which the contents are the following:

# Plugin Manifest
plugin:
    name: Plugin Test
    version: 1.0.0
    main: index.js

I'm not sure what's going on here. Do you know the issue?

From your stack trace, I believe you are giving a Buffer instance to Yaml.parse(), while it is expecting a string. We could definitely add more checks to provide a more understandable error, but you should give a string to Yaml.parse() and will be fine.

Okay. Thank you.