我注意到在尝试使用 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!