Forced to manually install npm modules

I have been having trouble installing node modules for a project via the standard npm install (it is though my setup is ignoring the package.json or the dependancies of dependancies).

I have resorted to having to manually npm install [filename] -g each package. I have got by up to this point, but I have gone to install a repository that has hundreds of packages and it is just not viable any more.

The familiar error...

module.js:338
throw err;
      ^
Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:336:15)

I haven't a clue how to fix it myself so any help would be appreciated!

(If it helps am running OS X Yosemite I installed everything with Brew and Node via the nodejs.org pkg)

-M

I've come across this issue. For some reason it tends to happen more often under Mac OS. Another reason can be bad internet connection

the problem comes from the fact that when some files (except "package.json") fail to be downloaded NPM doesn't mark the repository as failed. Resulting in not working code set.

You have a chance to get the whole repo tree working simply deleting everything and reinstalling. However, if the tree is big enough and error rate is high, there is low probability to succeed with the whole tree of modules.

Thus the only work-around (I had to do it on my own) is walk manually through all dependencies and locate missing ones. Often problem is that package.json of dependency is downloaded however other files (actual scripts) are missing. In this case you have to remove the folder and re-run npm i one level higher. This is laborious and unpleasant work