Reputation: 129
I am stuck with a lambda error yaml.DEFAULT_SCHEMA.extend is not a function
while running the below code.
class CustomYamlTag {
constructor(type, data) {
this.type = type;
this.data = data;
}
}
//Lambda handler
exports.handler = event => {
logger.info('Event', event);
const SCHEMA = yaml.DEFAULT_SCHEMA.extend(tags);
let TemplateBody = yaml.load(fs.readFileSync('templates/TEMPLATEFILE.yml', 'utf8'), { schema: SCHEMA });
....
I tried const SCHEMA = yaml.Schema.extend(tags);
and ended up with the error
yaml.Schema.extend is not a function
Any suggestions on how to fix this or what I am doing wrong?
Thanks in advance.
Upvotes: 0
Views: 294
Reputation: 129
The error was thrown as I was using js-yaml 3.9.0.
I upgraded from js-yaml 3.9.0 to js-yaml 4.0.0 version and this allowed me to use yaml.DEFAULT_SCHEMA.extend.
extend property was added to the package on versions after 4.0.0
Reference
https://observablehq.com/@rmw4269/js-yaml
Upvotes: 0