最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如果不是libtool

网站源码admin15浏览0评论

如果不是libtool

如果不是libtool

我试图从节点项目中调用C / C ++代码,当我执行npm install进行构建时,这给了我奇怪的类型错误

我正在将Anaconda与Python 3.7一起用作全局python。我也安装了python 2.7

所以我要做的是跑步

npm config set python /usr/local/bin/python

但是我仍然收到此错误

npm install                                                       ✔ master

> [email protected] install /Users/aa/binding
> node-gyp rebuild

  CC(target) Release/obj.target/nothing/node_modules/node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 611, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 28, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 43, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 246, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: cannot use a string pattern on a bytes-like object
make: *** [Release/nothing.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/aa/anaconda/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/Users/abhimanyuaryan/anaconda/bin/node" "/Users/aa/anaconda/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/aa/binding
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aa/.npm/_logs/2018-10-25T10_13_17_726Z-debug.log

******我的源代码:******

binding.cpp

#include <napi.h>

using namespace Napi;

String Hello(const CallbackInfo& info) {
  return String::New(info.Env(), "world");
}

void Init(Env env, Object exports, Object module) {
  exports.Set("hello", Function::New(env, Hello));
}

NODE_API_MODULE(addon, Init)

binding.gyp

{
  "targets": [
    {
      "target_name": "native",
      "sources": [
        "binding.cpp"
      ],
      "include_dirs": [
        "<!@(node -p \"require('node-addon-api').include\")"
      ],
      "dependencies": [
        "<!(node -p \"require('node-addon-api').gyp\")"
      ],
      "cflags!": ["-fno-exceptions"],
      "cflags_cc!": ["-fno-exceptions"],
      "defines": ["NAPI_CPP_EXCEPTIONS"]
    }
  ]
}

package.json] >>

{
  "name": "app",
  "version": "0.0.0",
  "private": true,
  "gypfile": true,
  "dependencies": {
    "node-addon-api": "^1.5.0"
  }
} 

[我试图从节点项目中调用C / C ++代码,当我执行npm install进行构建时,出现了奇怪的Type错误,我将Anaconda与Python 3.7一起用作全局python。我也有python 2.7 ...

回答如下:

Node.js和node-gyp现在支持Python 3。Python 2于2020年1月1日死亡。

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论