Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm Gulp dependencies missing, even after running npm install

I have a project that uses Gulp. I deployed my project onto my Ubuntu server and now want to compile the assets (which is all my gulpfile does at the moment). Having installed Node and npm I run npm install from my project's root to install the dependencies. The package.json reads as follows:

  ...},
  "devDependencies": {
    "bower": ">=1.3.12",
    "gulp": "^3.8.10",
    "gulp-concat": "^2.4.3",
    "gulp-less": "^2.0.1",
    "gulp-minify-css": "^0.4.3",
    "gulp-notify": "^2.2.0",
    "gulp-rename": "^1.2.0",
    "gulp-uglify": "^1.1.0"
  }...

Upon then inspecting the node_modules folder in my project root I can see directories for each of the dependencies indicating they were installed. However when I run gulp I get npm errors such as the below:

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

These seem to be dependencies of the my project's dependencies (as they are not referenced in my gulpfile), but why hasn't npm installed them?

I can manually install each one as the error arises but I then get another similar error for the next missing dependency.

How can I solve this?

like image 537
harryg Avatar asked Mar 23 '15 13:03

harryg


People also ask

How do I fix dependency problems in npm?

Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.

Does npm install install all dependencies?

By default, npm install will install all modules listed as dependencies in package.


1 Answers

The solution was to delete the node_modules folder and rerun npm install.

It looks like the initial install failed partially for some reason.

like image 92
harryg Avatar answered Oct 09 '22 16:10

harryg