Tag Archives: node-gyp

[solution] MAC: stack error: ` gyp ‘failed with exit code:1

[20200730 update]
at the bottom is the previous answer. I found this problem was not so simple, because searching gypfailed with exit code:1 was not specific enough, look at the error reported, in fact, it could be more detailed. Separator before the following is a solution, this solution can only solve the file node - gyp/lib/configure. Js: 305:16 fault, if it is the problem on the bottom of the reference solution. If not, take a closer look at your problem, and sometimes you'll find that another problem is the following:

ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
...
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
...
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found
...
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py", line 152, in <module>
    _new_sha1 = hashlib.sha1
AttributeError: 'module' object has no attribute 'sha1'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/eric/Desktop/admin-web/node_modules/watchpack-chokidar2/node_modules/fsevents
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

look at this problem, mainly is the /usr/local/Cellar/python @ 2/2.7.15/Frameworks/python framework Versions/2.7/lib/python2.7/hashlib. Py this file was wrong, and wrong is md5 and sha1 encryption methods, such as didn't find it. So the file problem, should be caused by our computer environment, the computer is certain that a library in addition to the problem, resulting in the execution of this file and encryption related libraries or methods are suspended. So when searching, you can search MAC ERROR:root:code for hash md5 was not found or something like that, and search on bing.com international version, so that if there are related questions on StackOverflow, you can see them directly. Sure enough, there's a problem here, the same thing that we had, and the main reason is that the openssl on our computer is not working. Maybe it's because we've installed multiple versions of Python, or maybe we've installed some software that comes with OpensSL that conflicts with the computer's own. So that's this guy. So, we need to respecify that.

# 先看看是什么版本,我的是1.0.2o_1
ls /usr/local/Cellar/openssl
# 指定切换到这个版本
brew switch openssl 1.0.2o_1
# 输出以下这样的就成功了
Cleaning /usr/local/Cellar/openssl/1.0.2o_1
Opt link created for /usr/local/Cellar/openssl/1.0.2o_1

1. Problem description

NPM installation error, all kinds of online uninstall and reinstall node-gyp methods have been tried to no use, but can not find the root of the problem:

gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.0.0
gyp ERR! command "/usr/local/Cellar/node/8.1.3/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/project/node_modules/ckmeans
gyp ERR! node -v vxx
gyp ERR! node-gyp -v vxxx
gyp ERR! not ok 

2, cause guess

gyp is a compilation tool, similar to the makefile command, it is mainly used to compile C++, node integrated it, called node-gyp0.

NPM is the source code for , NPM install is pull the source code in native compilation, after this time because inevitably, the source code used in other languages, such as C or C + +, compile time, so you need to other language compiler tools such as node - gyp , but the fact is that these compile tools in different systems is dependent on different system compiler tools, For example, on the MAC, this node-gyp actually relies on the compilation tools provided by xcode, so that's the problem I ran into. It's a xcode tool. Except for the problem, the tool management of xcode is xcode-select, which needs to be reset or installed or reset.

3. Solution

for the specific solution, see an issue of schnerd/d3-scale-cluster:

# 要不要sudo看自己当前用户是不是有sudo权限
$ [sudo] xcode-select --install
xcode-select: error: command line tools are already installed, 
use "Software Update" to install updates

# 提示已经安装的话,就重置
[sudo] xcode-select --reset

problem solved.