簡體   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