Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I load NPM packages in browser dev tools console?

Doing it this way:

const _ = await import('https://unpkg.com/lodash')

gives me a strange object with single Symbol(Symbol.toStringTag) prop valued "Module".

Note 1: I’m aware of the trick

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import _ from 'lodash'
window._ = _

in your code, please give your answer only if the import works directly from browser’s dev tools console.

Note 2: I’m also aware that this question has been asked many times. I read through all the answers, they either do not work nowadays or are inapplicable because of Note 1. So I decided to ask it again.

>Solution :

This is a lodash specific thing I recon as it uses an IIFE

await import("https://unpkg.com/lodash");
console.log(_, window._);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading