Node.js / npm - anyway to tell if a package is pure JS or not?

前端 未结 3 1733
北海茫月
北海茫月 2021-01-03 00:16

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. Aft

相关标签:
3条回答
  • 2021-01-03 00:51

    Look out for the "scripts" field in the package.json.

    If it contains something like

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

    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.

    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.

    That said many modules have been updated to install, without build on Windows, express for one. However that cannot be assured of all packages.

    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.

    0 讨论(0)
  • 2021-01-03 00:52

    Node is not "everything javascript" , since one way to extend node core is to write c/c++ plugins.

    So Node is more a javascript wrapper around c/c++ modules using V8.

    How could you write efficient database drivers in pure javascript for instance ? it would be possible but slow.

    as for the filters , it is up to the author to document his package. there is no automatic filter.

    0 讨论(0)
  • 2021-01-03 01:02

    The first solution doesn't tell you if a dependency makes the package impure or not. Much better to search for gyp generated output:

    find node_modules/ | grep binding.gyp || echo pure
    
    0 讨论(0)
提交回复
热议问题