npm install is missing modules

76,307

Solution 1

I've faced the same problem when bootstrapping a MEAN application and add each missing dependencie with npm install packageName --save was not an option so I came across to npm-install-missing whom has saved my life :)

Installation

npm install -g npm-install-missing

Usage

npm-install-missing

Solution 2

Running npm install will install all dependencies that are specified in the package.json. Seems like you have quite a few dependencies that are not defined that way. Use npm install packageName --save and npm will add the package to your package.json.

Solution 3

I am using the same version of npm/node. Sometimes, it is like npm is "lost". What I suggest is :

  • rm of your node modules (at least the one that is concerned)
  • npm cache clean
  • run "npm install" several times, until all dependencies are resolved and no message are displayed

Solution 4

It seems that gulp need 'karma' dependencies (socket.io ,di ,log4js...) so you will have to run :

npm install karma

so just runing this command solved the problem, and all should be good, the same thing happens with grunt as well for some reasons.

Share:
76,307

Related videos on Youtube

Jeanluca Scaljeri
Author by

Jeanluca Scaljeri

Updated on January 05, 2022

Comments

  • Jeanluca Scaljeri
    Jeanluca Scaljeri over 2 years

    Before I can run gulp in my project I need to run npm install. This works except on my computer, because I get the following error:

    Error: Cannot find module 'socket.io'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:280:25)
        at Module.require (module.js:364:17)
        ...
    

    I can fix this with

    $> npm install socket.io
    

    Now when I do the install command again I get

    Error: Cannot find module 'di'
        ...
    

    When I install di and run the install command again I get:

    Error: Cannot find module 'log4js'
    

    I think that this might continue for a very long time. Any suggestions what is going on here and how to fix this ?

    • Qwerty
      Qwerty about 4 years
      I have inherited a project where the original author apparently installed all dependencies globally or without -S flag. No answer here really answers this question. Is there not a way to automatically install all missing dependencies discovered as imported within the project files on build time by static analysis?
  • Jeanluca Scaljeri
    Jeanluca Scaljeri almost 10 years
    I have about 50 packages in my package.json file. As far as I know, the dependencies of these packages are handled by the package.json of these packages!
  • jgillich
    jgillich almost 10 years
    @JeanlucaScaljeri Yes they are. Do you use the latest version of Node & npm?
  • Omar Tarek
    Omar Tarek almost 7 years
    When I try this It tells me that I have no missing modules, although when I run npm list It is loaded with missing and unmet dependencies.
  • towry
    towry over 6 years
    This answer is not a solution. some missing module are dependencies of other module. npm: 2.15.1 have the same issue.
  • Jamie Hutber
    Jamie Hutber over 4 years
    For me this also says it is finished but does nothing sadly!
  • Qwerty
    Qwerty about 4 years
    This just goes through package.json in each dependency. I need to install dependencies, which are used in project, but somehow forgotten to install.
  • ptpaterson
    ptpaterson almost 4 years
    This answer was already provided in 2015. If you agree that using the npm-install-missing package answers the original poster's question, then give the answer a thumbs up. If you want to say something to clarify the answer, leave a comment under the answer, but don't create a new one.
  • Timo
    Timo about 3 years
    Since 2017 --save is not needed.
  • aniran mohammadpour
    aniran mohammadpour over 2 years
    I think it wouldn't need the dash(-) before i, !!
  • Gustavo Alexandre
    Gustavo Alexandre over 2 years
    It is 8 years old one, does not work in latest node
  • IOviSpot
    IOviSpot about 2 years
    Getting UnauthorizedAccess. This is why I hate these pesky platforms with 9000 dependencies, in which 75% are outdated. Just stick to C++.