-7

I'm new to lodash and i've have installed lodash as

npm i --save lodash

and im calling it in my index.js file as

import _ from 'lodash';

However this is not working and its displaying the error on console as

index.js:1 Uncaught SyntaxError: Unexpected identifier '_'

Im not using node.js

  • There are instructions on the homepage for the library. https://lodash.com/ – Quentin Oct 26 '18 at 10:52
  • First of all im not using node.js so this isnt a repeat, second i've tried that – Akshay Kishore Oct 26 '18 at 10:56
  • 2
    You skipped straight past the "in a browser" bit and onto "Using npm" … which is the package manager for Node.js which you claim you aren't using (and then from there you dived into ES6 imports which aren't mentioned anywhere on that page). – Quentin Oct 26 '18 at 10:57
  • Use [napa](https://github.com/shama/napa) to install `lodash.js` straight from github into `node_modules`: i.e. `npm i napa` then in your `package.json` specify a napa config block `"napa": {"lodash": "lodash/lodash#3.10.1"}` and also configure napa to run upon npm install with `"scripts": {"install": "napa"}`. You'll then have `node_modules/lodash/lodash.js` – DJDaveMark Nov 18 '20 at 13:16

1 Answers1

0

If you are using node.js try the following

var _ = require('lodash');
Sarthak Aggarwal
  • 2,024
  • 1
  • 6
  • 10