如何安装NODE_MODULE_VERSION 46 [英] How can I install NODE_MODULE_VERSION 46

查看:331
本文介绍了如何安装NODE_MODULE_VERSION 46的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用NODE_MODULE_VERSION 46安装Node.js版本?我一直遇到NODE_MODULE_VERSION不匹配的情况,并且重新编译没有帮助,因此切换节点版本可能会更容易.

How can I install a Node.js version using NODE_MODULE_VERSION 46? I keep running into a NODE_MODULE_VERSION mismatch, and recompiling hasn't helped so switching node versions might be easier.

基本上,我一直遇到这个问题:

Basically, I keep coming across this:

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.

So far, I've tried using n to change to different versions (one of my dependencies requires 4.9.1 or below), but that doesn't seem to change the NODE_MODULE_VERSION as recognized by the warning.

我也尝试过重新编译:

  • 我尝试删除node_modules并再次运行npm install. (此错误看起来像是来自项目根目录,但它也不适用于node_modules文件夹中的任何内容)
  • node-gyp configure --target=4.9.1 && node-gyp build --target=4.9.1.我是从此处想到的,希望我会比mxcd好运.
  • node-pre-gyp rebuild.我看到了 this ,并认为它可能对我有用.
  • I've tried deleting node_modules and running npm install again. (this error looks like it's coming from the project root, but it never worked for anything in the node_modules folder either)
  • node-gyp configure --target=4.9.1 && node-gyp build --target=4.9.1. I got the idea from here, and hoped I'd have better luck than mxcd.
  • node-pre-gyp rebuild. I saw this, and thought it might work for me.

这可在另一台运行无规图像的较旧计算机上使用.不幸的是,vagrant也不在新计算机上工作,所以我一直在从头开始尝试.有时,我想知道是否是因为我使用的是Ubuntu 18.04.运行docker映像时,服务器似乎无法超过16.04.

This works on another, older computer running a vagrant image. Unfortunately, vagrant isn't working on the new computer either, so I've been trying from scratch. Sometimes, I wonder if it's because I'm using Ubuntu 18.04. The server's can't seem to go past 16.04 when they run our docker image.

推荐答案

我知道了!

事实证明,我从node和nodejs获得了不同的版本

It turns out I was getting different versions from node and nodejs

$ node --version
v4.9.1
$ nodejs --version
v8.10.0

我升级到节点v8.10.0,重做所有操作,错误消失了!

I upgrade to node v8.10.0, redo everything, and the error's gone!

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也可以解决此问题.

I tried uninstalling nodejs (since this it's been replaced by just "node"), but node-grunt-cli requires it. I'm guessing that grunt uses nodejs instead of node to check its version, causing the error. The Ubuntu repositories have Grunt v0.4.5, while Grunt stable is at v1.0.3, so it's possible a newer version of grunt would also solve this problem.

这篇关于如何安装NODE_MODULE_VERSION 46的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆