标签: node-gyp

错误:找不到模块“nan”

我正在开发本机 Node.js 插件并关注nan docs

我将 nan 包含到 binding.gyp 中,例如: "include_dirs" : [ "<!(node -e \"require('nan')\")" ]

nan 也在 npm 依赖项中。

但是当我在另一个节点模块中安装包时,node-gyp 失败并出现错误

> nnb@1.0.2 install /Users/Shopgate/sandbox/stress/node_modules/nnb
> node-gyp rebuild

module.js:338
    throw err;
          ^
Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at [eval]:1:1
    at Object.exports.runInThisContext (vm.js:74:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:460:26)
    at evalScript (node.js:431:25)
    at startup (node.js:90:7)
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying …
Run Code Online (Sandbox Code Playgroud)

node.js npm node-gyp node.js-nan node.js-addon

33
推荐指数
4
解决办法
3万
查看次数

当试图配置或重建node-gyp时,得到错误:mac osx mavericks

我正在尝试运行node-gyp configure,但遇到以下错误:

gyp: binding.gyp not found (cwd: /usr/local/bin)
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "configure"
gyp ERR! cwd /usr/local/bin
gyp ERR! node -v v0.10.20
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
Run Code Online (Sandbox Code Playgroud)

我认为我在错误的目录中,但我不确定.我应该在哪个目录中运行它?

macos node.js node-gyp osx-mavericks

31
推荐指数
2
解决办法
2万
查看次数

Node.js:由于node-sass和node-gyp,找不到Python异常

突然在我的一个jenkins环境中构建已经开始失败,而在本地机器上它似乎工作正常,因为我安装了python,

从日志中我能够检测到问题是内部依赖,即来自node-sass v3.8.0的node-gyp v3.5.0,当我通过访问这个关于node- gyp的研究并发现需要安装Python的先决条件时.

所以我的问题是我可以安装什么版本的node-sass来绕过这个或者是否有更好的解决方案,因为我的构建在今天早上运行正常,在同一环境中.

节点v5.10.1

错误日志

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5
gyp verb `which` failed …
Run Code Online (Sandbox Code Playgroud)

node.js node-gyp node-sass

30
推荐指数
17
解决办法
5万
查看次数

npm install mongoose失败(kerberos和bson错误)

所以我试图启动我的节点应用程序,但我的MongoDB安装有一些错误.

以下是我的开发环境的规范:

node => 0.10.33(从nodejs.org安装)

npm => 1.4.28(从nodejs.org安装)

git => 2.1.3(自制)

mongodb => 2.6.5(自制)

如果它有所作为,我也使用Mean Stack Skeleton作为教程的一部分.

简而言之,当我尝试使用我的节点应用程序时$ node app.js,我得到以下反馈:

USER$ npm install mongoose

> kerberos@0.0.4 install /Users/USER/APP/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/kerberos/lib/kerberos.o
  CXX(target) Release/obj.target/kerberos/lib/worker.o
  CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
  CC(target) Release/obj.target/kerberos/lib/base64.o
  CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
  SOLINK_MODULE(target) Release/kerberos.node
  SOLINK_MODULE(target) Release/kerberos.node: Finished

> bson@0.2.15 install /Users/USER/APP/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bson/ext/bson.o
  SOLINK_MODULE(target) Release/bson.node
  SOLINK_MODULE(target) Release/bson.node: Finished
mongoose@3.8.18 node_modules/mongoose …
Run Code Online (Sandbox Code Playgroud)

kerberos mongoose bson npm node-gyp

24
推荐指数
4
解决办法
2万
查看次数

节点gyp配置得到“gyp ERR!找到VS”

我正在尝试开始了解节点 c/c++ 附加组件。该node-gyp命令有错误

我已经安装了vs2019,我的命令是

node-gyp configure --msvs_version=2019
Run Code Online (Sandbox Code Playgroud)

详细的输出是

gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@10.16.0 | win32 | x64
gyp info find Python using Python version 2.7.15 found at "C:\Users\seact\.windows-build-tools\python27\python.exe"
gyp ERR! find VS 
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio version 2019
gyp ERR! find VS VCINSTALLDIR not set, not running in …
Run Code Online (Sandbox Code Playgroud)

visual-studio node.js node-gyp visual-studio-2019

24
推荐指数
6
解决办法
4万
查看次数

在将node-gyp标志传递给包时,yarn添加包--build-from-source的行为类似于npm安装包--build-from-source吗?

看起来好像yarn没有将node-gyp标志传递给本机包npm.

例如,当尝试使用以下命令安装sqlite3@3.1.6时:

npm install sqlite3@3.1.6 \
  --build-from-source \
  --sqlite_libname=sqlcipher \
  --sqlite=`brew --prefix` \
  --verbose
Run Code Online (Sandbox Code Playgroud)

我们成功安装了带有sqlcipher扩展的sqlite3,由于传递--sqlite_libname而且--sqlite是在sqlite3 中指定binding.gyp.

但是,当试图使用yarn并运行我认为是等效的命令时,看起来标志不符合:

yarn add sqlite3@3.1.6 \
  --force \
  --build-from-source \
  --sqlite_libname=sqlcipher \
  --sqlite=`brew --prefix` \
  --verbose
Run Code Online (Sandbox Code Playgroud)

使用npm无法识别的命令行参数将转换为gyp标志.

有了yarn这似乎并没有工作.

有没有办法获得此功能yarn

node.js npm node-gyp yarnpkg

22
推荐指数
1
解决办法
3096
查看次数

Angular CLI - ng serve - 来自节点进程的高 CPU 使用率

我正在努力解决一个问题,即在本地运行任何 angular 应用程序时,链接到的节点进程ng serve使用了超过 100% 的 CPU 内核。

我现在的环境是:

Angular CLI:7.3.10 节点:11.15.0 操作系统:darwin x64 (Mac OS X Catalina 10.15.4) Angular:7.2.16

我遇到了很多关于此的帖子和问题,其中常见的解决方案似乎是fsevents针对 Mac OS 问题进行安装。

我尝试过的事情:

  • 安装 XCode 命令行工具node-gypfsevents在安装后重建
  • 安装最新版本的fsevents(2.1.3),因为旧版本被指定为 angular-cli (1.2.13) 的可选依赖项
    • 使用不同的节点版本,尝试 12.13.0 并删除 node_modules 并进行全新安装。还再次尝试了最新的 fevents 版本
    • 柜面其相关我nvm也使用
    • 试过 npm rebuild
    • 将我的一个应用程序从 Angular 7 升级到 9,在全新安装依赖项后仍然保持相同的行为,确保安装了 fsevents 并尝试了最新版本

无论我尝试什么,我一直观察到 CPU 使用率很高,我看到它有时会上升 300-400%。

这真的阻碍了我的发展,我希望有人可能有一些我可以尝试的好主意。

如果失败,我想知道是否应该尝试node完全卸载,摆脱nvm并从头开始。

更新 - 已解决

所以我走下了删除nvmnode关闭我的机器并从 …

fsevents node.js node-gyp webpack angular

21
推荐指数
2
解决办法
5393
查看次数

使用node-gyp进行本机绑定的交叉编译节点模块

我正在使用AWS Lambda,它涉及创建我的node.js脚本的存档,包括该node_modules文件夹并将其上传到他们的基础架构以运行.

这种方法很好,除了涉及具有本机绑定的节点模块(使用node-gyp).由于绑定已在我的本地计算机(OS X)上进行编译和项目存档,因此它与AWS(Amazon Linux)服务器不兼容.

如何交叉编译/安装节点模块(特别是node-sqlite3),这样当我将其上传到另一个服务器时,它会运行吗?

cross-compiling amazon-web-services node.js node-gyp aws-lambda

20
推荐指数
1
解决办法
3469
查看次数

如何调试nodejs的二进制模块?

我有一个用C++编写的node.js模块,它为C++库提供了一些绑定.库与SIGSEGV崩溃,所以我需要使用GDB调试它并找出问题所在.

我已经拥有了该模块的源代码./node_modules/somelib/,如果我转到该文件夹​​并输入npm install该库,则可以通过node.js中的require('somelib')进行编译.我可以将gdb附加到节点并重现错误,但在堆栈跟踪中我只是看到了node_modules/somelib/Release/somelib.node.

我不确定这是否重要但是库是使用编译的node-gyp.

  • 问题1:如何加载源代码或将gdb指向源代码?
  • 问题2:如何配置node-gyp生成调试符号?

c++ node.js node-gyp

19
推荐指数
2
解决办法
9166
查看次数

NPM:On OS X El Capitan上的"ld:找不到-lgcc_s.10.5的库"?

当我npm install用来安装这个存储库的依赖项时,我遇到了这样的错误:

> fsevents@0.3.8 install /Users/hanfeisun/Workspace/vue-webpack-example/node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild

  SOLINK_MODULE(target) Release/.node
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/.node] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command …
Run Code Online (Sandbox Code Playgroud)

macos node.js npm node-gyp

19
推荐指数
2
解决办法
6221
查看次数