如何使用 NODE_MODULE_VERSION 46 安装 Node.js 版本?我一直遇到 NODE_MODULE_VERSION 不匹配的情况,并且重新编译没有帮助,因此切换节点版本可能会更容易。
基本上,我一直遇到这样的情况:
Warning: The module '/home/cwaugh/workspaces/myproject/build/Release/addon.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`). Use --force to continue.
到目前为止,我已经尝试使用n
更改为不同版本(我的依赖项之一需要 4.9.1 或更低版本),但这似乎并没有改变警告所识别的 NODE_MODULE_VERSION 。
我也尝试过重新编译:
- 我尝试删除node_modules并运行
npm install
再次。 (这个错误看起来像是来自项目根目录,但它也对 node_modules 文件夹中的任何内容都不起作用)
-
node-gyp configure --target=4.9.1 && node-gyp build --target=4.9.1
。我的想法来自here https://stackoverflow.com/questions/54565777/node-gyp-compiling-against-wrong-node-module-version,并希望我的运气比 mxcd 好。
-
node-pre-gyp rebuild
. I saw this https://stackoverflow.com/questions/50805005/node-module-version-46-this-version-of-node-js-requires-node-module-version-64,并认为这可能对我有用。
这适用于另一台运行流浪图像的旧计算机。不幸的是,vagrant 也无法在新计算机上运行,所以我一直在从头开始尝试。有时,我想知道是否是因为我使用的是 Ubuntu 18.04。当服务器运行我们的 docker 镜像时,它们似乎无法超过 16.04。
我得到了它!
事实证明我从 Node 和 Nodejs 获得了不同的版本
$ node --version
v4.9.1
$ nodejs --version
v8.10.0
我升级到节点 v8.10.0,重做一切,错误消失了!
sudo npm install -g n
sudo n 8.10.0
rm -rf node_modules
npm install
node-gyp clean
node-gyp configure
node-gyp build
grunt build
grunt start
# No more NODE_MODULE_VERSION error
我尝试卸载nodejs(因为它已被“node”取代),但node-grunt-cli需要它。我猜测 grunt 使用 Nodejs 而不是 Node 来检查其版本,从而导致错误。 Ubuntu 存储库有 Grunt v0.4.5,而 Grunt 稳定版本为 v1.0.3,因此较新版本的 grunt 也可能会解决此问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)