Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neon build fails when used with napi-runtime #653

Closed
mattcollier opened this issue Dec 19, 2020 · 2 comments
Closed

neon build fails when used with napi-runtime #653

mattcollier opened this issue Dec 19, 2020 · 2 comments

Comments

@mattcollier
Copy link

My environment is Ubuntu 20.04 with [email protected]. I created my first project with instructions from: #444

neon new --no-default-features --features=napi-runtime napi-demo
cd napi-demo
npm install

Produces the following output: https://gist.github.com/mattcollier/3a94710fa8c1e6fd0e7de139742b219d#file-log-txt-L36
here is the error:

neon ERR! ENOENT: no such file or directory, copyfile '/home/matt/dev/napi-demo/native/target/debug/libnapi_demo.so' -> '/home/matt/dev/napi-demo/native/index.node'

Although there is logging generating native/index.node, no such file is created during neon install or neon build.

However, these steps do produce the proper index.node file.

cd native
cargo build

After this, I can successfully run the demo using node ./lib/index.js

@kjvalencik
Copy link
Member

neon-cli is no longer necessary for building with the n-api backend. https://github.com/neon-bindings/neon/blob/main/RELEASES.md#n-api

It also means that the structure built by neon new is incompatible. The replacement is being described in this RFC: neon-bindings/rfcs#36

Fortunately it's low effort to adapt the output. Remove the neon-cli dependency and replace the build with cargo build.

Keeping the native subdirectory isn't necessary, it can be flattened like in the tests: https://github.com/neon-bindings/neon/tree/main/test/napi

There is one known issue with the updated neon-build crate. It breaks cargo caching on cargo build. It will always relink the binary. cargo check is not impacted. If this isn't acceptible, the only thing neon-build does now is output the shared lib to index.node. It can be removed and replaced by a script in your project that copies from the target directory.

Let me know if you have any questions.

@mattcollier
Copy link
Author

@kjvalencik Thanks much. I'm on my way and since this appears to be a known issue, I'm closing it. Perhaps some of what you have just written would be a nice addition to the build instructions in #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants