Socket
Socket
Sign inDemoInstall

node-gyp

Package Overview
Dependencies
Maintainers
4
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gyp - npm Package Compare versions

Comparing version 8.4.1 to 9.0.0

docs/Force-npm-to-use-global-node-gyp.md

3

docs/binding.gyp-files-in-the-wild.md

@@ -48,2 +48,3 @@ This page contains links to some examples of existing `binding.gyp` files that other node modules are using. Take a look at them for inspiration.

* [sharp](https://github.com/lovell/sharp/blob/master/binding.gyp)
* [krb5](https://github.com/adaltas/node-krb5/blob/master/binding.gyp)
* [krb5](https://github.com/adaltas/node-krb5/blob/master/binding.gyp)
* [node-heapdump](https://github.com/bnoordhuis/node-heapdump/blob/master/binding.gyp)
# Updating the npm-bundled version of node-gyp
**Note: These instructions are (only) tested and known to work with npm 8 and older.**
**Note: These instructions will be undone if you reinstall or upgrade npm or node! For a more permanent (and simpler) solution, see [Force-npm-to-use-global-node-gyp.md](Force-npm-to-use-global-node-gyp.md). (npm 6 or older only!)**
[Many issues](https://github.com/nodejs/node-gyp/labels/ERR%21%20node-gyp%20-v%20%3C%3D%20v5.1.0) are opened by users who are

@@ -9,38 +13,61 @@ not running a [current version of node-gyp](https://github.com/nodejs/node-gyp/releases).

Generally, npm's library files are installed inside your global "node_modules", where npm is installed (run `npm prefix` and add `lib/node_modules`, or just `node_modules` for Windows). There are some exceptions to this. Inside this global `node_modules/` there will be an `npm/` directory and inside this you'll find a `node_modules/node-gyp/` directory. So it may look something like `/usr/local/lib/node_modules/npm/node_modules/node-gyp/`. This is the version of node-gyp that ships with npm.
This means that while `node-gyp` doesn't get installed into your `$PATH` by default, npm still keeps its own copy to invoke when you
attempt to `npm install` a native add-on.
When you install a _new_ version of node-gyp outside of npm, it'll go into your global node_modules, but not under the `npm/node_modules`. So that may look like `/usr/local/lib/node_modules/node-gyp/`. It'll have the `node-gyp` executable linked into your `PATH` so running `node-gyp` will use this version.
Sometimes, you may need to update npm's internal node-gyp to a newer version than what is installed. A simple `npm install -g node-gyp`
_won't_ do the trick since npm will still continue to use its internal copy over the global one.
The catch is that npm won't use this version unless you tell it to, it'll keep on using the one you have installed. You need to instruct it to by setting the `node_gyp` config variable (which goes into your `~/.npmrc`). You do this by running the `npm config set` command as below. Then npm will use the command in the path you supply whenever it needs to build a native addon.
So instead:
**Important**: You also need to remember to unset this when you upgrade npm with a newer version of node-gyp, or you have to manually keep your globally installed node-gyp to date. See "Undo" below.
## Version of npm
## Linux and macOS
We need to start by knowing your version of `npm`:
```bash
npm --version
```
npm install --global node-gyp@latest
npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
## Linux, macOS, Solaris, etc.
Unix is easy. Just run the following command.
If your npm is version ___7 or 8___, do:
```bash
$ npm explore npm/node_modules/@npmcli/run-script -g -- npm_config_global=false npm install node-gyp@latest
```
`sudo` may be required for the first command if you get a permission error.
Else if your npm is version ___less than 7___, do:
```bash
$ npm explore npm/node_modules/npm-lifecycle -g -- npm install node-gyp@latest
```
If the command fails with a permissions error, please try `sudo` and then the command.
## Windows
### Windows Command Prompt
Windows is a bit trickier, since `npm` might be installed to the "Program Files" directory, which needs admin privileges in order to
modify on current Windows. Therefore, run the following commands __inside a `cmd.exe` started with "Run as Administrator"__:
First we need to find the location of `node`. If you don't already know the location that `node.exe` got installed to, then run:
```bash
$ where node
```
npm install --global node-gyp@latest
for /f "delims=" %P in ('npm prefix -g') do npm config set node_gyp "%P\node_modules\node-gyp\bin\node-gyp.js"
Now `cd` to the directory that `node.exe` is contained in e.g.:
```bash
$ cd "C:\Program Files\nodejs"
```
### Powershell
If your npm version is ___7 or 8___, do:
```bash
cd node_modules\npm\node_modules\@npmcli\run-script
```
npm install --global node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
Else if your npm version is ___less than 7___, do:
```bash
cd node_modules\npm\node_modules\npm-lifecycle
```
## Undo
**Beware** if you don't unset the `node_gyp` config option, npm will continue to use the globally installed version of node-gyp rather than the one it ships with, which may end up being newer.
Finish by running:
```bash
$ npm install node-gyp@latest
```
npm config delete node_gyp
npm uninstall --global node-gyp
```

@@ -172,2 +172,4 @@ 'use strict'

candidates = [
'out/Release/lib.target/libnode',
'out/Debug/lib.target/libnode',
'out/Release/obj.target/libnode',

@@ -174,0 +176,0 @@ 'out/Debug/obj.target/libnode',

@@ -22,3 +22,4 @@ 'use strict'

// 2. and --force-process-config is not specified
const shouldReadConfigGypi = (gyp.opts.nodedir || gyp.opts['dist-url']) && !gyp.opts['force-process-config']
const useCustomHeaders = gyp.opts.nodedir || gyp.opts.disturl || gyp.opts['dist-url']
const shouldReadConfigGypi = useCustomHeaders && !gyp.opts['force-process-config']
if (shouldReadConfigGypi && nodeDir) {

@@ -25,0 +26,0 @@ try {

@@ -152,2 +152,6 @@ 'use strict'

if (name) {
// convert names like force_process_config to force-process-config
if (name.includes('_')) {
name = name.replace(/_/g, '-')
}
this.opts[name] = val

@@ -154,0 +158,0 @@ }

@@ -14,3 +14,3 @@ {

],
"version": "8.4.1",
"version": "9.0.0",
"installVersion": 9,

@@ -29,3 +29,3 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",

"graceful-fs": "^4.2.6",
"make-fetch-happen": "^9.1.0",
"make-fetch-happen": "^10.0.3",
"nopt": "^5.0.0",

@@ -39,3 +39,3 @@ "npmlog": "^6.0.0",

"engines": {
"node": ">= 10.12.0"
"node": "^12.22 || ^14.13 || >=16"
},

@@ -42,0 +42,0 @@ "devDependencies": {

@@ -34,3 +34,3 @@ # `node-gyp` - Node.js native addon build tool

* Python v3.6, v3.7, v3.8, or v3.9
* Python v3.7, v3.8, v3.9, or v3.10
* `make`

@@ -43,9 +43,11 @@ * A proper C/C++ compiler toolchain, like [GCC](https://gcc.gnu.org)

* Python v3.6, v3.7, v3.8, or v3.9
* [Xcode](https://developer.apple.com/xcode/download/)
* You also need to install the `XCode Command Line Tools` by running `xcode-select --install`. Alternatively, if you already have the full Xcode installed, you can find them under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`. This step will install `clang`, `clang++`, and `make`.
* Python v3.7, v3.8, v3.9, or v3.10
* `XCode Command Line Tools` which will install `clang`, `clang++`, and `make`.
* Install the `XCode Command Line Tools` standalone by running `xcode-select --install`. -- OR --
* Alternatively, if you already have the [full Xcode installed](https://developer.apple.com/xcode/download/), you can install the Command Line Tools under the menu `Xcode -> Open Developer Tool -> More Developer Tools...`.
### On Windows
Install the current version of Python from the [Microsoft Store package](https://docs.python.org/3/using/windows.html#the-microsoft-store-package).
Install the current version of Python from the [Microsoft Store package](https://www.microsoft.com/en-us/p/python-310/9pjpw5ldxlz5).

@@ -64,4 +66,4 @@ Install tools and configuration manually:

`node-gyp` requires that you have installed a compatible version of Python, one of: v3.6, v3.7,
v3.8, or v3.9. If you have multiple Python versions installed, you can identify which Python
`node-gyp` requires that you have installed a compatible version of Python, one of: v3.7, v3.8,
v3.9, or v3.10. If you have multiple Python versions installed, you can identify which Python
version `node-gyp` should use in one of the following ways:

@@ -68,0 +70,0 @@

@@ -32,1 +32,12 @@ 'use strict'

})
test('options with spaces in environment', (t) => {
t.plan(1)
process.env.npm_config_force_process_config = 'true'
const g = gyp()
g.parseArgv(['rebuild']) // Also sets opts.argv.
t.equal(g.opts['force-process-config'], 'true')
})

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc