0

I've created my first NodeJS module using lodash. When I install my module using npm i mymodule --save and run my index.js script using require('lodash') I get an error with a sub module...

Error : Error: Cannot find module 'lodash'

lodash is well installed but not in the root directory, in the modules directory...

tonymx227
  • 5,293
  • 16
  • 48
  • 91
  • possible duplicate of http://stackoverflow.com/questions/27431187/cannot-find-module-lodash – zerohero Jan 12 '17 at 13:51
  • 1
    Possible duplicate of [cannot find module "lodash"](http://stackoverflow.com/questions/27431187/cannot-find-module-lodash) – zerohero Jan 12 '17 at 13:51

1 Answers1

0

In the source tree of your module you need to run:

npm install lodash --save

And then publish a new version of your module to npm.

The package.json of your module needs to have lodash in its dependencies. If it doesn't then it will not get installed together with your module.

rsp
  • 107,747
  • 29
  • 201
  • 177