简体   繁体   English

dyld:找不到符号:_napi_module_register

[英]dyld: Symbol not found: _napi_module_register

Had my node working with the VS Code debugger last night no problem.昨晚让我的节点与 VS Code 调试器一起工作没问题。 I haven't touched anything besides install the npm mysql package.除了安装 npm mysql 包之外,我没有触及任何东西。

I come back tonight and its throwing this error:我今晚回来并抛出这个错误:

Debugger listening on [::]:49952
dyld: lazy symbol binding failed: Symbol not found: _napi_module_register
  Referenced from: /Users/adamsawyers/node_modules/bufferutil/prebuilds/darwin- 
 x64/node-napi.node
  Expected in: flat namespace
dyld: Symbol not found: _napi_module_register
  Referenced from: /Users/myusername/node_modules/bufferutil/prebuilds/darwin- 
 x64/node-napi.node
  Expected in: flat namespace

Apparently my installation of n (a node version handling package in npm) is busted somehow.显然,我安装的 n(npm 中的节点版本处理包)以某种方式被破坏了。 My research told me that napi_module_register is part of the n package, but I'm not sure how this got messed up especially since I had it working last night.我的研究告诉我 napi_module_register 是 n 包的一部分,但我不确定它是如何搞砸的,尤其是因为我昨晚让它工作了。

I tried reinstalling my node packages, reinstalling n, rebuilding the project file structure, even restarting my computer.我尝试重新安装我的节点包,重新安装 n,重建项目文件结构,甚至重新启动我的计算机。 Nothing has worked so far.到目前为止,一切都没有奏效。

Any suggestions?有什么建议?

Apparently VS code doesn't like v6.10.3 of nodejs which I am running to create lambda functions in AWS (that is the version specified by AWS)显然 VS 代码不喜欢 nodejs 的 v6.10.3,我正在运行它以在 AWS 中创建 lambda 函数(即 AWS 指定的版本)

I use the N package to manage my node version.我使用 N 包来管理我的节点版本。 After switching to the latest version 10.7.0 as of 07/25/2018 (command: sudo n latest) and rerunning the debugger in VS code, it worked perfectly在 2018 年 7 月 25 日切换到最新版本 10.7.0(命令:sudo n latest)并在 VS 代码中重新运行调试器后,它运行良好

I'm still unsure as the the cause, but hopefully others find this solution helpful我仍然不确定是什么原因,但希望其他人发现这个解决方案有帮助

This exact error happened to me because:这个确切的错误发生在我身上,因为:

  1. I needed socket.io to run on Node我需要socket.io在 Node 上运行
    • Which in turn needs ws (websockets on Node)这又需要ws (Node 上的 websockets)
  2. Also, I needed to run this on an outdated Node version (Node 7) for a very good reason (believe me, I would not want to do this if I wouldn't have to)另外,我需要在过时的 Node 版本(Node 7)上运行这个有一个很好的理由(相信我,如果我不需要的话,我不想这样做)
  3. However, trying to use it on that old version causes above error message.但是,尝试在旧版本上使用它会导致上述错误消息。

Solution解决方案

This is a terrible solution, but at least I got it to work.这是一个糟糕的解决方案,但至少我让它起作用了。

After some researching, I found no good solution to this.经过一番研究,我没有找到很好的解决方案。 However, a close look at the source code shows that there is a fallback.js next to index.js which implements the same functionality as the native build but without needing a build.但是,仔细查看源代码会发现index.js旁边有一个fallback.js ,它实现了与本机构建相同的功能,但不需要构建。 This will probably slow things down significantly, but at least it works:这可能会显着减慢速度,但至少它有效:

  1. yarn add module-alias
  2. prefix your actual code with this (eg via node -r fallbacks.js ):用这个前缀你的实际代码(例如通过node -r fallbacks.js ):
// fallbacks.js
const moduleAlias = require('module-alias');

const dependencyRoot = getDependencyRoot(); // whatever is your root folder, maybe __dirname + '..'

moduleAlias.addAlias('bufferutil', dependencyRoot + '/node_modules/bufferutil/fallback.js');
moduleAlias.addAlias('utf-8-validate', dependencyRoot + '/node_modules/utf-8-validate/fallback.js');


// run actual code here...

PS: In my case, in order to allow ws to run on Node 7, I also had to babel it, since its using modern synytax. PS:就我而言,为了让ws能够在 Node 7 上运行,我还必须对它进行 babel,因为它使用的是现代语法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 dyld:找不到符号:_node_module_register - dyld: Symbol not found: _node_module_register dyld:懒惰的符号绑定失败:找不到符号:_node_module_register - dyld: lazy symbol binding failed: Symbol not found: _node_module_register nodejs napi 模块没有自行注册 - nodejs napi module did not self register dyld:未找到符号:_JNI_CreateJavaVM - dyld: Symbol not found: _JNI_CreateJavaVM 节点opencv /特立独行的:dyld:找不到符号 - node-opencv / mavericks : dyld: Symbol not found 无法使用bcrypt登录用户(dyld:未找到符号) - Can't login a user using bcrypt (dyld: Symbol not found) macOS和dyld:未找到符号:_usdt_create_provider - macOS & dyld: Symbol not found: _usdt_create_provider ZMQ构建出现“ dyld:懒惰的符号绑定失败:找不到符号:”的原因? - Cause of “dyld: lazy symbol binding failed: Symbol not found:” error from ZMQ build? OSX 10.7.5上的node-gyp - dyld:惰性符号绑定失败:找不到符号 - node-gyp on OSX 10.7.5 — dyld: lazy symbol binding failed: Symbol not found 警告:错误:dyld:惰性符号绑定失败:找不到符号:_objc_autoreleasePoolPush - Warning: Error: dyld: lazy symbol binding failed: Symbol not found: _objc_autoreleasePoolPush
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM