应该在全局和本地安装 node-gyp 吗?

Should node-gyp be installed globally and locally?

我正在 https://github.com/nodejs/abi-stable-node-addon-examples 查看 nodejs 插件示例。

自述部分说我必须全局安装 node-gyp:

$ sudo npm install node-gyp -g

但是全局安装node-gyp后,是否还需要在本地项目中安装?

$ cd myproject
$ npm install node-gyp

最好全局安装 node-gyp 因为 node-gyp 的主要目的是构建 节点本机模块node-gyp 还需要像 visual studio 这样的工具(以防在 Windows 上构建) 和 python 也全局安装。

全局安装后无需本地安装。