Home>Article>Web Front-end> What to do if npm node gyp fails

What to do if npm node gyp fails

藏色散人
藏色散人 Original
2022-12-29 14:42:01 4113browse

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

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

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!

Statement:
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