napi-rs / website Goto Github PK
View Code? Open in Web Editor NEWWebsite for napi.rs
Home Page: https://napi.rs
License: MIT License
Website for napi.rs
Home Page: https://napi.rs
License: MIT License
neon gained better N-API support and removed legacy backend, Comparison with neon
should be updated to reflect that.
not working
As I stated here: napi-rs/napi-rs#1321 (comment)
a list of available macro arguments would be great. Or did I miss it?
Had to look through the sourcecode to find skip_typescript
I'm trying to use napi-rs at the moment for a project and I'm generally very impressed and grateful for what you have created.
Yesterday I had the experience of getting quite confused about an error which said
the trait
NapiValue
is not implemented for MyValue
And I couldn't see anything about MyValue
that would be causing the problem given how I was setting it up. It turned out that I had another struct with #[napi]
which had a pub value: MyValue
field and it was the pub
that was triggering the error. It never should have been pub
but I guess I typed it accidentally at some point. I realise it is hard to control the kind of errors that the compiler produces in this situation but I'm wondering if the docs could be extended to include a section about pub
fields and their implications and the kind of error that I ran into.
I would be happy to try to provide some text or a PR if that would be useful.
The description in the docs about prepublish
is: Running some preparation for publishing NAPI-RS packages.
is not helpful. At least there should be a warning that running prepublish command will publish all the platform packages to the NPM repository. I think you should more explicitly describe how the command works, similar to the artifacts page (some preparation
doesn't explain much).
Hi all, thanks for creating this project!
I appreciate the napi-rs auto-installer but I am interested in setting up a napi-rs project manually (I'm weird like that). I'd like to use my own build scripts, workspace setup, omit code-gen, package manager selection, etc. I essentially want a minimal napi-rs project that only produces a .node
file if possible.
In the past I have used Neon because of its unopinionated project integration but I find the napi-rs bindings to be very ergonomic and prefer to use them if possible.
I tried to deconstruct & bring over the project files produced by napi new
- but the napi-rs CLI obfuscates the native module build steps (napi build
) so I didn't get too far.
Are there instructions on setting up a project by hand?
The README has a bullet point claiming "Zero copy data interactive between Rust & Node.js".
All data is copied into/out of the JS virtual machine by definition. Rust, like every other foreign interface, cannot directly access the JS heap without risking race conditions with garbage collection.
This claim should be removed or corrected.
I tried either windows and WSL and it cannot use napi :
(base) nico@mypc:/mnt/d/$ yarn global add @napi-rs/cli
yarn global v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "@napi-rs/[email protected]" with binaries:
- napi
Done in 0.33s.
(base) nico@mypc:/mnt/d/$ napi
Command 'napi' not found, did you mean:
command 'nap' from snap nap-snippets (0.1.1)
command 'qnapi' from deb qnapi (0.1.9-1build2)
command 'nabi' from deb nabi (1.0.0-4)
See 'snap info ' for additional versions.
I found this dead link on https://github.com/napi-rs/website/blob/main/src/docs/introduction/release.mdx happy to remove it but I'd love to see what would have been in the recipes/publish-package
page as it's a major pain point in binary package distribution.
#[js_function(1)]
fn get_native_object(ctx: CallContext) -> Result<JsNumber> {
let count: i32 = ctx.get::<JsNumber>(0)?.try_into()?;
let mut this: JsObject = ctx.this_unchecked();
let native: Native = ctx
.env
.unwrap(&mut this)?;
ctx.env.create_int32(native.value + 1)
}
the count
is useless.
This example does not work.
I really have a hard time debugging the rust code with vs code. Its very difficult to find info about how to attatch my debugger to rust libraries that is used by node.js. Yarn build appears to make a project.so in the release folder. Is that what I need to debug my rust? I wish there was more information.
👋 Hi, thanks so much for creating this awesome tool to streamline the process of creating and publishing Node.js addon. I am following the https://napi.rs/docs/introduction/simple-package page to use it for the first time and had a good experience. I did ran into 2 issues however so I thought to drop some suggestions here.
Suggestion 1 is pertaining to the following statement in the doc
I'm using yarn to install the dependencies here, you can replace it by your favorite package manager.
I don't think the second half of this statement is correct. I initially used npm install
to install dependency, but CI doesn't like it because it uses yarn as config and it was expecting to find a yarn.lock
file, so I had to resort to yarn
to generate the lock file to make CI happy.
The following was the error I ran into previously
Run actions/setup-node@v4
Found in cache @ /Users/runner/hostedtoolcache/node/18.19.0/x64
Environment details
/Users/runner/.yarn/bin/yarn --version
1.22.19
/Users/runner/.yarn/bin/yarn cache dir
/Users/runner/Library/Caches/Yarn/v6
Error: Dependencies lock file is not found in /Users/runner/work//. Supported file patterns: yarn.lock
(Log based on https://github.com/xitanggg/enigo-node-insert-text/actions/runs/7324902521/job/19948934147)
Suggestion 2 is pertaining to the following statement in the doc
In order to publish packages in GitHub Actions, you need to configure the NPM_TOKEN environment variable in your GitHub repo.
In the project Settings -> Secrets, add your NPM_TOKEN into it.
Environment secret, environment variable, repository secret are 3 different things. The CI.yml
is actually using NPM_TOKEN
as a repository secret secrets.NPM_TOKEN
, so I'd suggest paraphrasing it with something like the following to make it more clear
In order to publish packages in GitHub Actions, you need to configure the NPM_TOKEN as a repository secret in your GitHub repo.
In the project Settings -> Secrets and variables -> Actions -> Repository secrets, add your NPM_TOKEN into it.
Thanks
Type Error: Cannot read property 'split' of undefined
at PrePublishCommand. (C:\Users\Administrator\AppData\Roaming\npm\node_modules@napi-rs\cli\scripts\index.js:135601:65)
at Generator.next ()
at fulfilled (C:\Users\Administrator\AppData\Roaming\npm\node_modules@napi-rs\cli\scripts\index.js:3454:58)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
配置文件无误
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
Warning
These dependencies are deprecated:
Datasource | Name | Replacement PR? |
---|---|---|
npm | @types/sharp |
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
package.json
@mdx-js/react ^3.0.0
@vercel/analytics ^1.1.1
lodash-es ^4.17.21
next 14.2.13
nextra 2.13.4
nextra-theme-docs 2.13.4
react ^18.2.0
react-dom ^18.2.0
@perfsee/webpack ^1.10.0
@types/node ^20.10.5
@types/react ^18.2.45
@types/sharp ^0.32.0
autoprefixer ^10.4.16
cross-env ^7.0.3
file-loader ^6.2.0
husky 9
lint-staged ^15.2.0
next-mdx-remote ^5.0.0
postcss ^8.4.32
prettier ^3.1.1
sharp ^0.33.1
tailwindcss ^3.4.0
typescript ^5.3.3
vercel ^37.0.0
yarn 4.5.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.