NPM package error: Cannot read property 'type' of undefined


#1

I’m new to glitch and javascript, but I can understand and use someone else’s code when it works. But I don’t know where to start when there’s an error.

I found an interesting package on npm (link) and wanted to try it. But usage example gives me an error. How should I figure out if there is something with the package or I’m just using it wrong?
(glitch project edit link)

var getYoutubeSubtitles = require(’@joegesualdo/get-youtube-subtitles-node’);

let videoId = ‘q_q61B-DyPk’

getYoutubeSubtitles(videoId)
.then(subtitles => {
console.log(subtitles)
})
.catch(err => {
console.log(err)
})


/app/node_modules/@joegesualdo/get-youtube-subtitles-node/index.js:7
9:16 PM
let type = options.type || ‘either’;
9:16 PM
^
9:16 PM
9:16 PM
TypeError: Cannot read property ‘type’ of undefined
9:16 PM
at getYoutubeSubtitles (/app/node_modules/@joegesualdo/get-youtube-subtitles-node/index.js:7:21)
9:16 PM
Jump to
at Object. (/app/server.js:14:1)
9:16 PM
at Module._compile (module.js:569:30)
9:16 PM
at Object.Module._extensions…js (module.js:580:10)
9:16 PM
at Module.load (module.js:503:32)
9:16 PM
at tryModuleLoad (module.js:466:12)
9:16 PM
at Function.Module._load (module.js:458:3)
9:16 PM
at Function.Module.runMain (module.js:605:10)
9:16 PM
at startup (bootstrap_node.js:158:16)
9:16 PM
at bootstrap_node.js:575:3


#2

Looks like a problem with package as the default example in the docs doesn’t work, but it does if you specify a value for type so options isn’t undefined: https://glitch.com/edit/#!/understood-stove?path=server.js:14:37