node-gyp编译node的c++插件的各种问题解决方案binding.node dll

18 篇文章 0 订阅
13 篇文章 1 订阅

node使用node-gyp编译的插件在开发和打包,会遇到很多不同的问题。往往搞到我们无从下手。以下是我的一些心得,希望适合您。

Error:

1. was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64

stderr:  D:\yiz\work\argos-2020-02-05\programs\release\
index.js:238 stderr:  win32\programs\server\node_modules\fibers\future.js:280
						throw(ex);
						^

Error: The module '\\?\D:\yiz\work\argos-2020-02-05\programs\release\win32\programs\server\npm\node_modules\usb\build\Release\usb_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

2. fibers\future.js usb_bindings.node is not a valid Win32 application.

stderr:  D:\yiz\work\argos-2020-02-05\programs\re
index.js:238 stderr:  lease\win32\programs\server\node_modules\fibers\future.js:280
						throw(ex);
						^

Error: \\?\D:\yiz\work\argos-2020-02-05\programs\release\win32\programs\server\npm\node_modules\usb\build\Release\usb_bindings.node is not a valid Win32 application.

\\?\D:\yiz\work\argos-2020-02-05\programs\release\win32\programs\server\npm\node_modules\usb\build\Release\usb_bindings.node

可能的解决方法:

一、安装node模块时,注意打印信息内容:

1.普通node环境安装usb模块

npm i usb命令:

PS D:\yiz\work\argos-2020-02-05> npm i usb

> usb@1.6.2 install D:\yiz\work\argos-2020-02-05\node_modules\usb
> prebuild-install --verbose || node-gyp rebuild

prebuild-install info begin Prebuild-install version 5.3.3
prebuild-install info looking for cached prebuild @ C:\Users\seeing\AppData\Roaming\npm-cache\_prebuilds\7ae3e9-usb-v1.6.2-node-**v64-win32**-x64.tar.gz
prebuild-install info found cached prebuild
prebuild-install info unpacking @ C:\Users\seeing\AppData\Roaming\npm-cache\_prebuilds\7ae3e9-usb-v1.6.2-node-v64-win32-x64.tar.gz
prebuild-install info unpack resolved to D:\yiz\work\argos-2020-02-05\node_modules\usb\build\Release\usb_bindings.node
prebuild-install info unpack required D:\yiz\work\argos-2020-02-05\node_modules\usb\build\Release\usb_bindings.node successfully
prebuild-install info install Successfully installed prebuilt binary!
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install
peer dependencies yourself.
npm WARN eslint-plugin-vue@5.2.3 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-eslint-parser@5.0.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.2.1 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.2.1 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN The package nw-builder is included as both a dev and production dependency.

+ usb@1.6.2
added 21 packages from 16 contributors and updated 1 package in 7.143s
2.meteor环境内安装usb模块

meteor npm i usb命令:

PS D:\yiz\work\argos-2020-02-05> meteor npm i usb

> usb@1.6.2 install D:\yiz\work\argos-2020-02-05\node_modules\usb
> prebuild-install --verbose || node-gyp rebuild

prebuild-install info begin Prebuild-install version 5.3.3
prebuild-install info looking for cached prebuild @ C:\Users\seeing\AppData\Roaming\npm-cache\_prebuilds\997bd6-usb-v1.6.2-node-**v57-win32**-x64.tar.gz
prebuild-install info found cached prebuild
prebuild-install info unpacking @ C:\Users\seeing\AppData\Roaming\npm-cache\_prebuilds\997bd6-usb-v1.6.2-node-v57-win32-x64.tar.gz
prebuild-install info unpack resolved to D:\yiz\work\argos-2020-02-05\node_modules\usb\build\Release\usb_bindings.node
prebuild-install info unpack required D:\yiz\work\argos-2020-02-05\node_modules\usb\build\Release\usb_bindings.node successfully
prebuild-install info install Successfully installed prebuilt binary!
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install
peer dependencies yourself.
npm WARN eslint-plugin-vue@5.2.3 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-eslint-parser@5.0.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.2.1 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.2.1 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN The package nw-builder is included as both a dev and production dependency.

+ usb@1.6.2
added 21 packages from 16 contributors and updated 1 package in 6.382s

**区别:**生成的usb包一个是v64,另一个是v57。
**原因:**可能meteor npm在安装的时候做了一些处理,或者环境不一样。

二、对比开发环境和打包后的生产环境node版本异同:

因为有时候我们开发的环境里面的各种软件,跟生产环境的软件版本不同,会造成各种问题。所以我们要理清软件运行要依赖的各种环境是否一致。
如何查看node环境,可以在cmd(命令提示符)中:
输入:node进入node环境,
然后输入:process查看所有信息。
在这里插入图片描述

相关解决方案

https://segmentfault.com/a/1190000016565228?utm_source=tag-newest

https://www.cnblogs.com/wangyuxue/p/11218113.html

https://blog.csdn.net/you23hai45/article/details/86236769

欢迎大神留言讨论!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值