Node.js / npm - 无论如何判断包是否是纯JS? [英] Node.js / npm - anyway to tell if a package is pure JS or not?

查看:190
本文介绍了Node.js / npm - 无论如何判断包是否是纯JS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到尝试用npm安装看似简单的节点包(例如神经,一个微框架)我经常遇到某种形式的依赖性痛苦。在进行了一些挖掘之后,我通过 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.

所以,我的问题是:是否有任何过滤器/依赖关系跟踪可用让你看看一个包除节点核心外是否还有其他依赖关系?因为对我而言,节点的诱惑力是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似乎是最佳选择。 在窗口上开发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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆