Lodash gets invalid module error

Requiring lodash was working until yesterday, but today suddenly I am getting an invalid module error:

I’ve checked lodash and they haven’t had any updates in a few months, and I also tried Tom’s module debugger which resulted in an undefined:
_ = require(‘lodash@4.17.11/lodash.js’).catch(() => window._)
_ = undefined

I’m wondering if there’s any changes on Observable’s end that’s causing this?

Thank you!

Hey Shirley!

Looks like a bug or regression on jsDelivr’s side. The require() method uses jsDelivr as a middleman to request npm package contents over http, and the lodash package resource this call results in ( https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.js ) is truncated, which is why it’s invalid JavaScript, not just an invalid module. I just filed an issue with jsDelivr to try and get to the bottom of the issue.

In the meantime, you can work around the issue by using unpkg instead:

_ = require("https://unpkg.com/lodash@4.17.11/lodash.js")


1 Like

This also appears to work:


(update from jsDelivr, the temporary bug with truncated content is fixed and they’re hunting down the root cause)