当前位置: 首页 > 面试题库 >

错误:无法安装“ pre”版本的节点,请改用--nodedir标志

湛安宁
2023-03-14
问题内容

我正在尝试为节点安装opencv。我认为这与opencv没有直接关系,而是与node-
gyp有关。我在Mac上成功安装了opencv,但是当我尝试在Ubuntu服务器上执行完全相同的操作时,在执行“ npm install
opnecv”后出现以下错误:

npm http GET https://registry.npmjs.org/opencv
npm http 304 https://registry.npmjs.org/opencv

> opencv@0.0.7 preinstall /home/demo/node_modules/opencv
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack     at install (/usr/local/lib/node_modules/node-gyp/lib/install.js:69:16)
gyp ERR! stack     at Object.commands.forEach.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/node-gyp/lib/node-gyp.js:56:37)
gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/node-gyp/lib/configure.js:181:20)
gyp ERR! stack     at /usr/local/lib/node_modules/node-gyp/lib/configure.js:101:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:538:7)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:96:17)
gyp ERR! stack     at maybeClose (child_process.js:638:16)
gyp ERR! stack     at Process._handle.onexit (child_process.js:680:5)
gyp ERR! System Linux 3.2.0-29-generic
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/demo/node_modules/opencv
gyp ERR! node -v v0.8.13-pre
gyp ERR! node-gyp -v v0.7.1
gyp ERR! not ok 
npm ERR! opencv@0.0.7 preinstall: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the opencv@0.0.7 preinstall script.
npm ERR! This is most likely a problem with the opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls opencv
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-29-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "opencv"
npm ERR! cwd /home/demo
npm ERR! node -v v0.8.13-pre
npm ERR! npm -v 1.1.63
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/demo/npm-debug.log
npm ERR! not ok code 0

我还尝试下载源代码并执行“ node-gyp rebuild”,结果类似:

demo@camera:~/src/node$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@0.7.1
gyp info using node@0.8.13-pre | linux | x64
gyp ERR! configure error 
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack     at install (/usr/local/lib/node_modules/node-gyp/lib/install.js:69:16)
gyp ERR! stack     at Object.commands.forEach.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/node-gyp/lib/node-gyp.js:56:37)
gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/node-gyp/lib/configure.js:181:20)
gyp ERR! stack     at /usr/local/lib/node_modules/node-gyp/lib/configure.js:101:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:538:7)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:96:17)
gyp ERR! stack     at maybeClose (child_process.js:638:16)
gyp ERR! stack     at Process._handle.onexit (child_process.js:680:5)
gyp ERR! System Linux 3.2.0-29-generic
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/demo/src/node
gyp ERR! node -v v0.8.13-pre
gyp ERR! node-gyp -v v0.7.1
gyp ERR! not ok

有人遇到过这个问题吗?


问题答案:

使用npm install --nodedir=/path/to/node opencv,其中/path/to/node是当前nodejs源代码的路径。

发生这种情况是因为node-
gyp找不到您的自定义版本的源,下面是有关它的讨论:https : //github.com/TooTallNate/node-
gyp/issues/86

如果您具有超级用户权限,通常可以通过创建符号链接来解决此问题。

chmod a+r /path/to/node -R
cd /usr/lib
sudo ln -s /path/to/node node

然后npm install,它很可能会找到它。如果/ usr / lib / node已经存在,请不要执行此操作,因为其他软件可能依赖于此。



 类似资料:
  • 当我试图用maven安装一个项目时,我遇到了这个错误。我看了很多帖子说这个错误是因为maven使用了另一个版本的java,但这不是我的情况(我想),因为我运行的每个命令都说使用的版本是java 1.7。 这是终端的结果: mvn的输出-版本 Java Home:< code >/Library/Java/JavaVirtualMachines/JDK 1 . 7 . 0 _ 79 . JDK/Co

  • 我有一个很多人都有的错误,我认为我在这里找到了一个解决方案。本质上,它是说我的节点版本与node-sass版本不兼容。很多人都有同样的问题,所以我相信链接会有所帮助。然而,当我运行npm安装node-sass@4.14.1时,我得到了一个不同的错误。我知道这是一些简单的修复,但我找不到它!有人明白这是怎么回事吗?

  • 我想在我的laravel 5.7.11应用程序中使用elasticsearch,并进行了一些搜索,我发现了插件laravel-scout-relastic(https://github.com/ericktamayo/laravel-scout-relastic)。我首先尝试了elasticsearch/elasticsearch和laravel-scout-relastic插件,然后最后显示错误

  • 我正试图在子文件夹中运行,但我一直收到以下错误: msbuild:错误msb3428:未能加载Visual C组件 我的机器上安装了Visual Studio代码和.NET framework,因此我不确定如何避免此错误。如有任何建议,将不胜感激。 运行Microsoft 7专业版

  • 运行此命令时,无法安装Laravel 6.0: 我想安装,但它附带。 如何下载laravel的最新版本?我的版本是

  • 我正在尝试用Java14安装netbeans。 我在犯错误- 下面是我的java详细信息- 我的操作系统详细信息是-