【问题标题】:How to update the NodeJS version in linux? (Issue occurs when trying to install jsreport-pdf-password)如何在 linux 中更新 NodeJS 版本? (尝试安装 jsreport-pdf-password 时出现问题)
【发布时间】:2019-04-04 05:10:52
【问题描述】:
2019-04-04T04:34:49.035Z - error: Error when loading extension Error: The module '/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-pdf-password/node_modules/hummus/binding/hummus.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`).
Error: The module '/media/vishesh/Disc/working/examples/jsreport_pdf_password_install_tryout/node_modules/jsreport-pdf-password/node_modules/hummus/binding/hummus.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`).

我曾尝试使用 nvm 降级节点版本。我已经成功完成并减少到所需的版本(即)8.9.1。因此,当我检查命令“node -v”时,我得到 8.9.1。

但是当我检查“nodejs -v”时,我只得到 11.9.0。因此发生了上述错误。我也无法确定如何更改 nodejs 版本?有什么想法吗?

另外,我尝试在完全不同的文件夹中的 node 和 nodejs 中安装具有相同版本 11.9.0 的“jsreport-pdf-password”,并且还删除了 node_modules。仍然出现此错误。

【问题讨论】:

    标签: node.js installation node-modules nvm


    【解决方案1】:

    使用命令nvm install 8.9.1下载节点版本后,它将下载该版本但不会使用它。要使用 8.9.1 版,您必须运行另一个命令 nvm use 8.9.1。然后您的节点版本管理器将开始使用 8.9.1。

    【讨论】:

    • 我不仅降级了。我确实使用了 nvm use commad。事实上,我什至运行了这个命令来设置默认版本“nvm alias default 8.9.1”。
    • 您使用的是哪个版本的nvm?您可以通过命令nvm version 查看 nvm 版本。安装最新版本的nvm,然后重试nvm use 8.9.1
    • 我使用的是 1 周前安装的最新版本。版本是“11.9.0”。
    【解决方案2】:

    我明白了。我在 stackoverflow 中搜索了一段时间,发现 node 是 npm 用于 nodejs 的别名。 nodejs 是 ubuntu 操作系统安装的 nodejs 版本的别名。因此,我使用此命令“sudo apt-get remove nodejs”删除了 nodejs。

    然后我使用 nvm 并将 7.10.0 设置为默认节点版本。后来安装了包 jsreport-pdf-password 并运行了代码。现在运行时没有任何版本不匹配的错误。

    就软件包而言,它需要节点版本 7 以及更高或更低的任何版本,就会出现相关错误。我什至尝试在更高版本中重建包,但它没有解决问题。因此,如果您的节点版本大于 7,我建议不要使用此包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-30
      • 2021-12-19
      • 1970-01-01
      • 2023-01-13
      • 1970-01-01
      • 2021-07-02
      • 2021-05-07
      • 2020-09-24
      相关资源
      最近更新 更多