Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find node-gyp dependency (..or any dependency) in npm project

I am going through unimaginable frustration trying to get a project to run (ie. by calling 'npm install') that always trips over node-gyp. I am on windows so I need to install python and something like Visual Studio.

Long story short... I do not want to have a dependency on a festering pile of s*** like Visual Studio, so I want to see if somehow this node-gyp could somehow be optional, or be gotten rid of.

Now if I open my package.json file I find these dependencies.

  "devDependencies": {
    "autoprefixer-stylus": "^0.7.1",
    "browser-sync": "^2.8.2",
    "gulp": "^3.9.0",
    "gulp-cache": "^0.3.0",
    "gulp-concat": "^2.6.0",
    "gulp-if": "^1.2.5",
    "gulp-imagemin": "^2.3.0",
    "gulp-minify-html": "^1.0.4",
    "gulp-nunjucks-html": "^1.2.2",
    "gulp-order": "^1.1.1",
    "gulp-plumber": "^1.0.1",
    "gulp-stylus": "^2.0.6",
    "gulp-uglify": "^1.2.0",
    "gulp-util": "^3.0.6",
    "jeet": "^6.1.2",
    "kouto-swiss": "^0.11.13",
    "minimist": "^1.1.3",
    "rupture": "^0.6.1"
  },
  "dependencies": {
    "gulp-install": "^0.6.0"
  }

I can see the dependency tree of each of these packages by going here :

http://npm.anvaka.com/#/

However if I go through every single one of these dependencies I cannot see the node-gyp dependency anywhere for any of these.

Is there something I don't understand about dependencies? What uses node-gyp? And why?

like image 368
Oliver Watkins Avatar asked Nov 25 '15 10:11

Oliver Watkins


2 Answers

node-gyp is required for native C/C++ Add ons as mentioned in the doc here

The dependencies are built on each target platform. For windows platforms it requires visual studio as mentioned in their installation notes here

node-gyp is itself not mentioned in package.json (probably because it requires global installation) so, you will have to manually see if any of dependencies or its nested dependencies are using native c/c++ add ons either by their repo or downloaded source code or the npm install log itself. One way could be in npm_modules folder search for file binding.gyp or .cc/.cpp files, and you should be able to locate the culprit npm module.

like image 173
prasun Avatar answered Oct 18 '22 02:10

prasun


npm ls lists installed dependencies in your project. npm ls node-gyp will limit node-gyp's sub-tree.

npm-remote-ls lists all dependencies of a remote package. You an manually go through or use grep

I created findep which is a lot faster than both (for this purpose). It can check your local project, an external npm package, or even a remote github project, and has a --greedy option that stops as soon as it finds the specified dependency.

# Checks if current project has a 'node-gyp' dependency
findep node-gyp

# Checks if the npm package 'node-sass' has a 'node-gyp' dependency
findep node-gyp -e node-sass

# Greedily checks if the project 'AngularClass/angular2-webpack-starter' has at least one of these dependencies including "devDependencies":
$ findep he mime lodash ms -GDr -e AngularClass/angular2-webpack-starter
Looking for [he, mime, lodash, ms] in AngularClass/angular2-webpack-starter...
Found 16 dependencies that use [he, mime, lodash, ms]:
assets-webpack-plugin > lodash
string-replace-loader > lodash
karma-coverage > lodash
like image 35
laggingreflex Avatar answered Oct 18 '22 01:10

laggingreflex