专栏名:话说node-gyp遇到的坑
所有者:cava丶zhang

这两天在用c++写nodejs的addon.

首先说一下自己的状态:

windows 下 node-gyp configure build 成功

然后npm publish。

在linux下使用npm install cava-coolpad-rsa

发现编译错误。

c++代码没问题。后来出来一个错误

 > cava-coolpad-rsa@0.0.5 install /home/node_modules/cava-coolpad-rsa
> node-gyp rebuild

Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py",
line 18, in <module>
    sys.exit(gyp.script_main())
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__in
it__.py", line 534, in script_main
    return main(sys.argv[1:])
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__in
it__.py", line 527, in main
    return gyp_main(args)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__in
it__.py", line 503, in gyp_main
    options.circular_check)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__in
it__.py", line 129, in Load
    params['parallel'], params['root_targets'])
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/inpu
t.py", line 2692, in Load
    variables, includes, depth, check, True)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/inpu
t.py", line 362, in LoadTargetBuildFile
    includes, True, check)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/inpu
t.py", line 219, in LoadOneBuildFile
    None)
  File "binding.gyp", line 1
    {
     ^
SyntaxError: invalid syntax
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/npm/nod
e_modules/node-gyp/lib/configure.js:340:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:
12)
gyp ERR! System Linux 2.6.32-358.6.2.el6.x86_64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/b
in/node-gyp.js" "rebuild"
gyp ERR! cwd /home/node_modules/cava-coolpad-rsa
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok
npm ERR! cava-coolpad-rsa@0.0.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cava-coolpad-rsa@0.0.5 install script.
npm ERR! This is most likely a problem with the cava-coolpad-rsa 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 cava-coolpad-rsa
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.32-358.6.2.el6.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "cava-cool
pad-rsa"
npm ERR! cwd /home/c++demo
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/c++demo/npm-debug.log
npm ERR! not ok code 0

错误很多,看的头晕,其实真正的错误只有一句话:

File "binding.gyp", line 1
        {
         ^
    SyntaxError: invalid syntax

就是说,我的binding.gyp格式有问题,检查发现,把所谓的tab和空格去掉,就没问题了。

猜想:大概是空格和tab不能共存吧。

好吧,猜想正确:空格和tab混用的都该烧死。。。

~~~请python的同学轻点儿“骚”

现在一切搞定,很感谢 死月

= '订阅者:' 邮件订阅(0)
成员
暂无文章
我的收藏