node-gyp编译addon: UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd5 in position 0: invalid con

17 篇文章 1 订阅
10 篇文章 0 订阅

在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"

总结:

        无力吐槽有些东西,浪费生命。

逆向安全与正向开发收徒中,需要的联系

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值