Node.js / npm - anyway, to find out if the package is pure JS or not?

I noticed that when I try to get seemingly simple node packages for installation with npm (for example, nerve , micro-framework ") I often encounter some form of pain depending. After some digging, I found a problem with a nerve in bcrypt module, which is apparently written in C / C ++ and should be compiled by the package manager after loading.

Unfortunately, it seems that if you want this to work on Windows, the answer (from one of the problems with bcrypt problems) "installs Linux VM". So today I did it and started working in other dependencies (you need certain unnamed apt packages installed before you can even think about building, even though GCC is installed) then in the end, seeing another C compiler error (about some package or another that “Arrays.c” could not find, I think), I really gave up and switched from a nerve to express instead. Ironically, larger and more complex express installations with npm on Linux and Windows without any one problem.

So my question is: is there access to filtering / dependency tracking that allows you to see if the package has additional dependencies besides node core? Because for me, the appeal of node is “everything in Javascript,” and this kind of thing is pretty unpleasant to scatter the illusion. In fact, despite the fact that I did more than my time working with C / C ++, whenever I see a demand to "do" something these days, I usually run in the other direction, shouting: )

+6
source share
3 answers

Take a look at the "scripts" field in package.json.

If it contains something like

"scripts": { "install": "make build", } 

and Makefile in the root directory, there is a good chance that the package has its own built-in module that needs to be compiled and built. Many packages include makefiles for test compilation only.

This verification of package documents does not preclude compilation and assembly of some dependency. This would mean repeating this process for every dependency in package.json, their dependencies, etc.

This suggests that many modules have been updated for installation, without assembly on Windows, for one. However, this cannot be guaranteed for all packages.

Using a Linux virtual machine seems like a better alternative. Developing Node.js applications in a window gives step-by-step instructions for installing a virtual machine, Node.js, and Express.

+4
source

The first solution does not mean that addiction makes the packaging unclean or not. It is much better to look for gyp-generated output:

 find node_modules/ | grep binding.gyp || echo pure 
+7
source

Node is not “all javascript,” since one way to extend the core of a node is to write c / C ++ plugins.

So node is more of a javascript wrapper around c / C ++ modules using V8.

How could you write efficient database drivers in pure javascript? it would be possible, but slowly.

as with filters, the author must document his package. no auto filter.

+2
source

Source: https://habr.com/ru/post/915420/


All Articles