我正在终端上运行一个节点应用程序。最近已经升级到节点v8.5.0,但我得到这个错误:

Error: The module '/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. 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`).
    at Object.Module._extensions..node (module.js:653:18)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/bcrypt.js:6:16)
    at Module._compile (module.js:624:30)
    at Module._extensions..js (module.js:635:10)
    at Object.require.extensions.(anonymous function) [as .js] (/tidee/tidee-au/packages/tidee-au-server/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/server/helpers/encryptPass.js:1:16)

知道怎么解决吗?


当前回答

运行NPM config set python python2.7,再运行NPM install, party is on。

其他回答

在尝试了不同的东西之后。 这工作。

删除节点模块文件夹并运行

npm i

我在grpc模块中遇到了同样的问题,在我的情况下,我正在使用电子,并在env变量“export npm_config_target=1.2.3”中设置了错误的电子版本,将其设置为我正在使用的电子版本,解决了我的问题。希望这能帮助那些设置env变量的人(https://electronjs.org/docs/tutorial/using-native-node-modules#the-npm-way)

简单地运行:

NPM卸载bcrypt

紧随其后的是:

NPM install bcrypt(或者NPM install,如果bcrypt在你的包中被声明为依赖项)。json文件)

运行NPM config set python python2.7,再运行NPM install, party is on。

在我的例子中,我运行的是nodejs而不是node。由于nodejs是由包管理器安装的:

# which node
/home/user/.nvm/versions/node/v11.6.0/bin/node

# which nodejs
/usr/bin/nodejs