cannot found lodash in npm installation

687 views Asked by At

I installed lodash and several other libraries this way:

npm install grunt-contrib-jshint --save-dev
npm install grunt-contrib-testem --save-dev
npm install sinon --save-dev
npm install -g phantomjs
npm install lodash --save
npm install jquery --save

When I run testem using grunt (or directly), I found the following problem

ReferenceError: _ is not defined

Digging into the issue, I found the issue in the mode following line

module.exports = require('./lodash');

(I have to point that the ./ is added by the installer. I even tried to remove it, but the error persist)

This is located on index.js, inside the node_modules/lodash folder I think this is an issue of installation, but no matter what I do, it continue failing. I update npm, I remove node_modules and install all over again, but this continue happens.

Any advice or clue will be greatly appreciate

1

There are 1 answers

1
AudioBubble On

You don't need to pass the relative path of modules that are inside the node_modules directory, just passing the module name will do the trick:

require('lodash');

Now node.js will automatically look inside the node_modules directory for you, simple as that <3.