繁体   English   中英

如何在npm项目中查找node-gyp依赖项(..或任何依赖项)

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

我正经历着无法想象的挫败,试图使一个项目总是运行在node-gyp上而无法运行(即通过调用'npm install' )。 我在Windows上,因此我需要安装python和类似Visual Studio的工具。

长话短说...我不想像Visual Studio那样依赖一堆令人讨厌的s ***,所以我想看看这个node-gyp是否可以以某种方式是可选的,或者可以摆脱。

现在,如果我打开package.json文件,我会发现这些依赖关系。

  "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"
  }

我可以通过以下步骤查看每个软件包的依赖关系树:

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

但是,如果我经历了这些依赖关系中的每一个,我就无法在任何地方看到node-gyp依赖关系。

关于依赖项,我是否不了解? 什么使用node-gyp? 又为什么呢

节点-GYP需要natice C / C ++添加附件如文档中提到这里

依赖关系建立在每个目标平台上。 对于Windows平台,需要Visual Studio,如此处的安装说明中所述

package.json没有提到node-gyp本身(可能是因为它需要全局安装),因此,您将必须手动查看是否有任何依赖项或其嵌套的依赖项是通过其repo还是下载的源使用本机c / c ++插件代码或npm安装日志本身。 一种方法可能是npm_modules文件夹中搜索文件binding.gyp.cc/.cpp文件,你应该能够找到罪魁祸首NPM模块。

查找其依赖项

npm ls node-gyp

npm ls列出项目中已安装的依赖项。 npm ls node-gyp将限制node-gyp的子树。

npm-remote-ls列出了远程软件包的所有依赖项。 您手动检查或使用grep

我创建了findep ,它比两者都快很多(为此目的)。 它可以检查您的本地项目,一个外部npm包,甚至是一个远程github项目,并且具有--greedy选项,该选项一旦找到指定的依赖项便会停止。

# 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

node-gyp用于为节点编译本机附加模块。 您是否看过这里的文档,特别是Windows信息? 另外,看看这个问题以了解解决Visual Studio要求的方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM