I am including lodash v.4.17.11 js file in my HTML web page using HTML script
tag.
<body>
...
<script src=".js/4.17.11/lodash.core.min.js"></script>
</body>
Some functions like _.filter()
or _.reduce()
are working fine, but _.remove()
gave me:
Uncaught TypeError: _.remove is not a function
It seems that this function does not exist in the library file! although it is listed in the documentation.
How should I do to solve this? Thank you!
.17.11#remove
I am including lodash v.4.17.11 js file in my HTML web page using HTML script
tag.
<body>
...
<script src="https://cdnjs.cloudflare./ajax/libs/lodash.js/4.17.11/lodash.core.min.js"></script>
</body>
Some functions like _.filter()
or _.reduce()
are working fine, but _.remove()
gave me:
Uncaught TypeError: _.remove is not a function
It seems that this function does not exist in the library file! although it is listed in the documentation.
How should I do to solve this? Thank you!
https://lodash./docs/4.17.11#remove
Share Improve this question edited Feb 17, 2023 at 13:32 Moritz Ringler 16.1k10 gold badges27 silver badges45 bronze badges asked May 24, 2019 at 20:16 Ahmed IsmailAhmed Ismail 93211 silver badges22 bronze badges 4-
Can you add the line where you import/require
lodash
from you code? – Akrion Commented May 24, 2019 at 20:57 -
<script src="https://cdnjs.cloudflare./ajax/libs/lodash.js/4.17.11/lodash.core.min.js"></script> </body>
– Ahmed Ismail Commented May 24, 2019 at 21:46 -
Are you importing specifically functions from lodash or using the entire lib? for example do you have something like
import { filter } from 'lodash'
? – Akrion Commented May 24, 2019 at 21:49 - No, I am including the whole library file from cdnjs url – Ahmed Ismail Commented May 24, 2019 at 21:52
2 Answers
Reset to default 6You are using the core
lib. It seems you need more than the core
:
instead of:
https://cdnjs.cloudflare./ajax/libs/lodash.js/4.17.11/lodash.core.min.js
use:
https://cdnjs.cloudflare./ajax/libs/lodash.js/4.17.11/lodash.min.js
Here are more details on the differences:
https://github./lodash/lodash/wiki/Build-Differences
For your convenience:
4 kB (gzipped) core build (63 methods; Backbone ≥ v1.3.0 patible)
_.assignIn, _.before, _.bind, _.chain, _.clone, _.pact, _.concat, _.create, _.defaults, _.defer, _.delay, _.each, _.escape, _.every, _.filter, _.find, _.flatten, _.flattenDeep, _.forEach, _.has, _.head, _.identity, _.indexOf, _.isArguments, _.isArray, _.isBoolean, _.isDate, _.isEmpty, _.isEqual, _.isFinite, _.isFunction, _.isNaN, _.isNull, _.isNumber, _.isObject, _.isRegExp, _.isString, _.isUndefined, _.iteratee, _.keys, _.last, _.map, _.matches, _.max, _.min, _.mixin, _.negate, _.noConflict, _.noop, _.once, _.pick, _.reduce, _.result, _.size, _.slice, _.some, _.sortBy, _.tap, _.thru, _.toArray, _.uniqueId, _#value, & _.values
Limitations:
- No _.matchesProperty iteratee shorthand
- No deep property path support
- No lazy evaluation
- No placeholder support
- No robust cloning (arrays & plain objects only)
- No support for maps, sets, & typed arrays
For me, I used "lodash": "^4.17.21"
, it worked normally until a pretty day, I don't know why I received this error message:
Uncaught TypeError: _.remove is not a function
Other lodash
functions still work, except the _.remove()
.
I tried to remove and reinstall lodash
by npm
but it didn't solve the problem.
I also looked up in folder node_modules
and found file remove.js
was still there.
Then I tried import { remove } from 'lodash'
as an alternative way and finally the error's gone.
Hope this help!