node.js 什么是节点gyp

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39739626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:35:18  来源:igfitidea点击:

What is node-gyp

node.jsnode-gyp

提问by selftaught91

Can anyone explain me what is node-gypand why it uses my system files to build Node.JS packages.

谁能解释一下node-gyp它是什么以及为什么它使用我的系统文件来构建 Node.JS 包。

  1. If Ii build a node project and it used node-gypinternally.
  2. Then I just tar that project and moved to a different system
  3. I untar it there and try to use it
  1. 如果我构建了一个节点项目并在node-gyp内部使用。
  2. 然后我只是 tar 那个项目并转移到另一个系统
  3. 我在那里解压并尝试使用它

Will this approach work?

这种方法会奏效吗?

回答by vuza

node-gypis a tool which compiles Node.js Addons. Node.js Addons are native Node.js Modules, written in C or C++, which therefore need to be compiled on your machine. After they are compiled with tools like node-gyp, their functionality can be accessed via require(), just as any other Node.js Module.

node-gyp是一个编译 Node.js 插件的工具。Node.js 插件是原生 Node.js 模块,用 C 或 C++ 编写,因此需要在您的机器上编译。使用 node-gyp 等工具编译它们后,它们的功能可以通过 访问require(),就像任何其他 Node.js 模块一样。

If you do what you suggested the module won't work, you will need to compile it/build it with node-gyp on the system you moved the program to.

如果你做了你建议的模块不起作用,你需要在你将程序​​移动到的系统上使用 node-gyp 编译它/构建它。

node-gyp: https://github.com/nodejs/node-gyp

node-gyp: https://github.com/nodejs/node-gyp

Node.js Addons: https://nodejs.org/api/addons.html

Node.js 插件:https: //nodejs.org/api/addons.html