Skip to content

Instantly share code, notes, and snippets.

@abitrolly
Last active December 21, 2019 19:11
Show Gist options
  • Save abitrolly/1cb9d3781e44a44c84b615e15aca526b to your computer and use it in GitHub Desktop.
Save abitrolly/1cb9d3781e44a44c84b615e15aca526b to your computer and use it in GitHub Desktop.

How to run JavaScript module from npm in Firefox console

Firefox can not print objects with circular references, and an external library is needed to print deeply nested object structures.

>> JSON.stringify(web3, null, 2)
TypeError: cyclic object value

eval + fetch is the easies way to load a library, such as lodash into console scope.

>> fetch('https://cdn.jsdelivr.net/npm/lodash@4.17.15/lodash.min.js')
       .then(response => response.text())
       .then(text => eval(text))
>> _.VERSION
"4.17.15"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment