错误:找不到模块"nan" [英] Error: Cannot find module 'nan'
本文介绍了错误:找不到模块"nan"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在研究本机Node.js插件,并遵循 nan docs
I'm working on native Node.js addon and following nan docs
我将nan包含在binding.gyp中,例如:
"include_dirs" : [ "<!(node -e \"require('nan')\")" ]
I included nan into binding.gyp like:
"include_dirs" : [ "<!(node -e \"require('nan')\")" ]
nan也属于npm依赖项.
Also nan is in npm dependencies.
但是当我在另一个节点模块中安装软件包时,node-gyp因错误而失败
But when I install the package inside the another node module node-gyp is failed with error
> 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 to load binding.gyp
推荐答案
全局安装nan
:
npm i -g nan
然后
export NODE_PATH=$(npm root -g)
这篇关于错误:找不到模块"nan"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文