I previously had my project building and running fine at Ionic2 beta 11. After following the instructions to update to rc0 (I used the “Copying your Project to a New Project method”) I have the following error when running ionic serve:
lodash.js does not export find
The import line I’m using in the offending file is:
import { find } from ‘lodash’;
As described in the instructions I installed the lodash types using this command:
npm install @types/lodash --save-dev --save-exact
Also as described in the instructions I ensured there is no typings.json file or typings directory.
It doesn’t matter which lodash method I try to use, I always get the same problem. Does anyone know what I’m doing wrong here?
Here’s my Ionic info
Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: 1.8.5
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.6.0
Xcode version: Xcode 8.0 Build version 8A218a
I’m getting errors like below during bundling:
[19:25:05] rollup: Export ‘get’ is not defined by ‘…/services/auth-service.js’
[19:25:05] rollup: Export ‘reverse’ is not defined by ‘…/products/products.js’
[19:25:05] rollup: Export ‘values’ is not defined by ‘…/products/products.js’
This is driving me nuts. I have been trying for the past 3 days and I still couldn’t find a solution.
I ran this to install lodash:
npm install @types/lodash --save --save-exact
I don’t have lodash in my dependencies but I do have @types/lodash in my devDependencies:
“dependencies”: {
“ionic-angular”: “^2.0.0-rc.0”,
“ionicons”: “^3.0.0”,
"@ionic/storage": “^1.0.3”,
“ionic-native”: “^2.0.3”
},
“devDependencies”: {
"@ionic/app-scripts": “^0.0.23”,
"@types/lodash": “4.14.36”,
"@types/moment": “2.13.0”,
“typescript”: “^2.0.3”
},
To import lodash in a ts file:
import _ from ‘lodash’;
To use lodash in a method
_.get( … );
_.reverse( … );
_.values( … )
Don’t do this. Never touch anything under node_modules manually. npm will cause you pain over and over again. Read this for how to properly override config files.