Home > Web Front-end > Front-end Q&A > What to do if npm node gyp fails

What to do if npm node gyp fails

藏色散人
Release: 2022-12-29 14:42:01
Original
4246 people have browsed it

npm node gyp failed because the versions of "node-gyp.js" and "Node.js" did not match. The solution: 1. Clear the node cache through "npm cache clean -f"; 2. Pass "npm install -g n" installs the n module; 3. Install the "node v12.21.0" version through the "n v12.21.0" command.

What to do if npm node gyp fails

#The operating environment of this tutorial: Windows 10 system, node v12.21.0 version, Dell G3 computer.

What should I do if npm node gyp fails?

npm install reported node-gyp related errors

When I was building a vue project, I reported node-gyp build related errors. The error message is as follows

1 error generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/xingxin/code_sxf2/nft-server/nft-ui/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 20.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/xingxin/code_sxf2/nft-server/nft-ui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/xingxin/code_sxf2/nft-server/nft-ui/node_modules/node-sass
gyp ERR! node -v v16.15.1
Copy after login

After various attempts, I discovered that

The reason is that node-gyp.js does not match my Node.js version, and my Node version is too high

After attempts After discovering that Node was downgraded to v12.21.0, the build was successful.

Commands related to downgrade operations:

# 查看当前node版本
node –v
# 清除node缓存
npm cache clean -f
# 安装n模块
npm install -g n
# 安装v12.21.0版本
n v12.21.0
# 查看当前node版本
node –v
Copy after login

Recommended learning: "node.js Video Tutorial"

The above is the detailed content of What to do if npm node gyp fails. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template