-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Updating npm's bundled node gyp
npm bundles its own, internal, copy of node-gyp. This internal copy is independent of any globally installed copy of node-gyp that
you may have installed via npm install -g node-gyp.
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.
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.
So instead:
We need to start by knowing your version of npm:
npm --versionUnix is easy. Just run the following command.
If your npm is version 7, do:
$ npm explore npm/node_modules/@npmcli/run-script -g -- npm_config_global=false npm install node-gyp@latestElse if your npm is version less than 7, do:
$ npm explore npm/node_modules/npm-lifecycle -g -- npm install node-gyp@latestIf the command fails with a permissions error, please try sudo and then the command.
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:
$ where nodeNow cd to the directory that node.exe is contained in e.g.:
$ cd "C:\Program Files\nodejs"If your npm version is 7, do:
cd node_modules\npm\node_modules\@npmcli\run-scriptElse if your npm version is less than 7, do:
cd node_modules\npm\node_modules\npm-lifecycleFinish by running:
$ npm install node-gyp@latest