I am using React and Redux. Inside my Reducer I am using lodash
library.
debugger;
command stops the execution
If I import lodash
library
import _ from "../../node_modules/lodash";
or
import _ from "lodash";
It fails. It cannot import the library. There is no loading error when I run my React application. I was wondering how do you load an external library(i.e lodash
) in Google Chrome console?
Use dynamic import syntax instead, and you'll get back a Promise with what you want. For example, on this page:
https://stackoverflow.com/questions/57032914/loading-external-library-in-chrome-console
using
import('../../foo')
results in
Assuming that on your own site, the link is proper, all you need to do is call .then
on the Promise:
import("../../node_modules/lodash")
.then((_) => {
// do stuff with _
});
(of course, this requires that node_modules
be a subfolder of the grandparent directory of the current page)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With