When I try to use lodash in my angular applications (built from angular-seeds) it's returning '_' not defined but the lodash package is in my node_modules. What else do i need to do to include it?
Are you using any build tools? If so you may need to add the module to the build script. Otherwise just include the js file just like any other script tag <script src="/node_modules/lodash/dist/lodash.min.js"></script>
Your angular application executes in the browser. What the node_modules folder contains is irrelevant. angular-seeds seems to use bower for application dependencies. node modules are used by the tooling (karma, etc.)
@JBNizet It's being more and more common for people to ditch bower and use npm exclusively. Personally I prefer the set up you're describing (mainly because of how bower resolves conflicts), but it doesn't apply to everyone.
The packages that you have installed using 'npm' are saved in node_modules that are used for server side whereas packages installed using 'bower' are saved in 'public/lib' folder. So the correct way to install lodash for angularjs is
Sign up to request clarification or add additional context in comments.
Comments
0
Having lodash in your node_module doesn't do everything by itself. This problem usually occurs when you have not included the actual file. Add it to your index.
<script src="/node_modules/lodash/dist/lodash.min.js"></script>