1

I'm trying to use lodash in angular 2.4.0

angular-cli : "@angular/cli": "1.0.0-rc.4",

Tried to import like this import * as _ from 'lodash';

Also tried

npm install --save lodash npm install --save @types/lodash 

package.json

{ "name": "travelz", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^4.1.3", "@angular/common": "^2.4.0", "@angular/compiler": "^2.4.0", "@angular/core": "^2.4.0", "@angular/forms": "^2.4.0", "@angular/http": "^2.4.0", "@angular/platform-browser": "^2.4.0", "@angular/platform-browser-dynamic": "^2.4.0", "@angular/router": "^3.4.0", "@types/lodash": "^4.14.37", "core-js": "^2.4.1", "intl": "^1.2.5", "lodash": "^4.16.4", "rxjs": "^5.1.0", "zone.js": "^0.7.6" }, "devDependencies": { "@angular/cli": "^1.0.0-rc.4", "@angular/compiler-cli": "^2.4.0", "@types/jasmine": "2.5.38", "@types/node": "~6.0.60", "codelyzer": "~2.0.0", "jasmine-core": "~2.5.2", "jasmine-spec-reporter": "~3.2.0", "karma": "~1.4.1", "karma-chrome-launcher": "~2.0.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^0.2.0", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.0", "ts-node": "~2.0.0", "tslint": "~4.5.0", "typescript": "~2.0.0" } } 

getting these errors:

C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8599,32): ',' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8602,14): ']' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8602,15): ';' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8605,26): ',' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8605,42): '(' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8605,61): ',' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8605,66): ')' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8607,15): ';' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8607,25): Declaration or statement expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8608,23): ')' expected.) C:/xampp/htdocs/travelz/node_modules/@types/lodash/index.d.ts (8608,46): '(' expected.) 

Can anyone please help?

2

1 Answer 1

1

need to install the lodash under @types.

$ npm install --save lodash $ npm install --save @types/lodash 

Then import it like this

import * as _ from "lodash"; 
Sign up to request clarification or add additional context in comments.

4 Comments

tried but it is giving different errors now
@NikhilRadadiyawhat is the error ?
@sachilaranawaka updated question, please check
@RahulSingh updated question please check

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.