Coder Social home page Coder Social logo

Comments (3)

annie-elequin avatar annie-elequin commented on June 11, 2024

Slight progress. Here's what I did...

  1. Fork this repo
  2. Comment out the flags (that didn't work)
  3. Put the flags back in

I then got a different error even though I hadn't changed anything.

New error:

# [github.com/Automattic/napi-go](http://github.com/Automattic/napi-go)

../../../go/pkg/mod/github.com/!automattic/[email protected]/instance_data.go:5:10: fatal error: 'node/node_api.h' file not found
#include <node/node_api.h>
^~~~~~~~~~~~~~~~~
1 error generated.

Figured that out - it was because napi-go expects node to be at /usr/local/include/node and mine is under .nvm.

So I did this:

sudo ln -s /Users/<username>/.nvm/versions/node/v21.7.3/include/node /usr/local/include/node

(I also added node-gyp with these commands, and my simple binding.gyp file that does nothing is in the above linked repo)

  • yarn add -D node-gyp
  • then add a binding.gyp file
  • node-gyp configure (requires the binding.gyp file)
  • node-gyp build

SO NOW

I run this:

go build -buildmode=c-shared -o "example.node" .

and we have this error:

cgo: cannot parse $WORK/b046/_cgo_.o as ELF, Mach-O, PE or XCOFF

and I think I might post on stack overflow? I see some other issues of this online but I haven't been able to figure out the solution

from napi-go.

ACenterA avatar ACenterA commented on June 11, 2024

@annie-elequin are you on mac arm ?

We had a similar issue and we fixed it by editing the various node_api_...flags to adjust the -arch x86_64

Note: We also used go1.18 to make it work though, not sure if it works on 1.19+

from napi-go.

annie-elequin avatar annie-elequin commented on June 11, 2024

@ACenterA
yes that did it!
here are the changes to our flags that we made that worked:
image

from napi-go.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.