問題描述
我注意到在嘗試使用 npm 安裝看似簡單的節點包時(例如 nerve,一個微框架")我經常遇到某種形式的依賴痛苦.經過一番挖掘,我找到了 bcrypt 模塊的問題,即顯然是用 C/C++ 編寫的,必須在包管理器下載后進行編譯.
I've noticed that in trying to get seemingly simple node packages to install with npm (e.g. nerve, a "micro-framework") I often run into some form of dependency pain. After some digging, I tracked down the problem with nerve to the bcrypt module, which is apparently written in C/C++ and has to be compiled after the package manager downloads it.
不幸的是,如果您希望它在 Windows 上運行,答案似乎是(來自 bcrypt 問題線程之一)安裝 Linux VM".所以今天早些時候我就這樣做了,并開始遇到其他依賴項(你需要 某些未命名的 apt 包 在你甚至可以考慮構建之前安裝,盡管安裝了 GCC),然后最終在看到另一個 C 編譯器錯誤之后(關于某些包或其他無法找到Arrays.c我想),我實際上放棄了,而是從神經轉為表達.具有諷刺意味的是,在 Linux 和 Windows 上使用 npm 進行更大更復雜的快速安裝卻沒有任何問題.
Unfortunately, it seems like if you want this to work on Windows, the answer is (from one of the bcrypt issues threads) "install a Linux VM". So earlier today I did just that, and started running into other dependencies (you need certain unnamed apt packages installed before you can even think about building, despite GCC being installed), then eventually after seeing yet another C compiler error (about some package or other not being able to find "Arrays.c" I think), I actually gave up, and switched from nerve to express instead. Ironically, the larger and more complicated express installs with npm on Linux and Windows without a single issue.
所以,我的問題是:是否有任何可用的過濾器/依賴項跟蹤可以讓您查看包是否具有除節點核心之外的其他依賴項?因為對我來說,node 的魅力是Javascript 中的一切",而這種東西非常令人不快地消除了這種錯覺.事實上,盡管我在使用 C/C++ 方面所做的工作已經超過了我的時間,但現在每當我看到需要制作"某些東西時,我通常都會尖叫著朝另一個方向跑去.:)
So, my question is: is there any filter / dependency tracking available that lets you see if a package has additional dependencies besides node core? Because to me the allure of node is "everything in Javascript", and this kind of stuff dispels the illusion quite unpleasantly. In fact, despite having done more than my time working with C/C++, whenever I see a requirement to "make" something these days I generally run in the other direction screaming. :)
推薦答案
注意 package.json 中的scripts"字段.
Look out for the "scripts" field in the package.json.
如果它包含類似的東西
"scripts": {
"install": "make build",
}
和根目錄中的 Makefile,包很可能有一些必須編譯和構建的本機模塊.許多軟件包包含一個僅用于編譯測試的 Makefile.
and a Makefile in the root directory, there's a good possibility that the package has some native module which would have to be compiled and built. Many packages include a Makefile only to compile tests.
對包文件的檢查并不排除必須編譯和構建某些依賴項的可能性.這意味著對 package.json 中的每個依賴項、它們的依賴項等重復此過程.
This check on the package documents does not exclude the possibility that some dependency will have to be compiled and built. That would mean repeating this process for each dependency in the package.json, their dependencies and so on.
也就是說,許多模塊已更新安裝,無需在 Windows 上構建,僅此而已.然而,這不能保證所有的包.
That said many modules have been updated to install, without build on Windows, express for one. However that cannot be assured of all packages.
使用 Linux VM 似乎是最好的選擇.在 Window 上開發 Node.js 應用程序 為您提供安裝 VM、Node.js 和 Express 的分步說明.
Using a Linux VM seems to be the best alternative. Developing Node.js applications on Window gives you step by step instructions on installing a VM, Node.js and Express.
這篇關于Node.js/npm - 無論如何判斷一個包是否是純 JS?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!