在addon项目中运行node-gyp configure命令出现以下错误:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 0: invalid continuation byte
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\xxxxxx\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:259:16)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
网上找了好多办法,都没有解决。
最终猜测是否是windows下的环境默认为gbk, 但编译环境需要utf-8,
测试:
在当前命令窗口中执行: chcp 65001, 果然就能正常运行了
下在给一个永久设置windows命令行为utf8的办法
将以下内容作为注册表.reg导入即可
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"autorun"="chcp 65001"
总结:
无力吐槽有些东西,浪费生命。