Code Monkey home page Code Monkey logo

examples's Introduction

neon-examples

Github Actions

Examples and common patterns for Neon.

All examples are for napi-backend. For examples using legacy-backend see the legacy branch.

Table of Contents

Example Description
async-sqlite Async interface to a SQLite database
cpu-count Return the number of CPUs
gzip-stream Asynchronously compress a stream of data
hello-world Return a JS String with a greeting message
tokio-fetch Asynchronously fetch a node release date

Contributing

Setup

The examples repository uses the npm 7 workspaces feature.

# npm 7 is required
npm --version

git clone https://github.com/neon-bindings/examples.git
cd examples
npm install

Tests

npm test

examples's People

Contributors

amilajack avatar dependabot[bot] avatar eventualbuddha avatar kjvalencik avatar syohex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

electron-example fails on npm run build

I've followed the guide here: https://neon-bindings.com/docs/electron-apps/

At the step 5 where one runs npm run build, it fails with this message.

neon ERR! spawn cargo ENOENT

Error: spawn cargo ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
electron-build-env error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `electron-build-env neon build neon-hello --release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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!     C:\Users\Stromberg\AppData\Roaming\npm-cache\_logs\2020-05-19T01_52_00_043Z-debug.log

I'm on Windows 10, here are relevant parts of the package.json.

"scripts": {
  "build": "electron-build-env neon build neon-hello --release",
  "start": "electron ."
},
"devDependencies": {
  "electron-build-env": "^0.2.0",
  "neon-cli": "^0.4.0"
},
"dependencies": {
  "electron": "^8.3.0",
  "@amilajack/neon-hello": "^1.0.2"
}

Request: Example of database connection in Rust

I'd like to request an example with the following characteristics:

  • a database connection in Rust (e.g. sled or BTreeMap)
  • a function exposed to JS to read from the database
  • a function exposed to JS to write to the database

I've tried to create a simple example of this myself but haven't had success - I'm not sure if it can be achieved with classes or if it needs use of JsBox from the N-API, but based on the docs, but it seems like Rust structs can't be mutated once boxed / once encapsulated in a class. Presumably there's a way of doing this that I'm unaware of?

add documentation to event-emitter

We have here a bunch of code, but no documentation: https://github.com/neon-bindings/examples/tree/master/event-emitter

It would be nice to know:

  • How to build it? (probably something like npm install neon; neon build)
  • How to use it? (probably something like var EvEm = require("event-emitter"); ...)

It looks like there's a lot of code there. Could we perhaps pare it down to just an event emitter example and split the polling and other stuff into a second example?

It's probably perfect as-is for a quick reference for those that are familiar with Rust and with neon and I may be very much in the minority, but I'm looking at neon as an excuse to become more familiar with Rust and although I know that what I need is right in front of me, I don't know enough to easily pick it out yet.

Async error not working

In the async folder, when changing the text from pass to whatever, the error does never actually reach the JS code. How can I send an error from the perform function up to the main thread?

Make it more understandable: primitives

primitives is not very kind for beginers who need the examples. This idea is to better more:

  1. Split the fn primitives for each JS primitive types
  2. Call the all of splitted functions from lib/index.js with printing then it will be show 7 ( or 6 ) types/lines.
  3. Append an useful link to the souce code commenting about JS primitive types for helpful.

Workflow:

  1. Approval by the authors and colaborators
  2. Modifying
  3. PR & Merge

related #50

Error on Yarn Build

I'm hitting issues on building the examples from the initial yarn step. I'm thinking it may have something to do with my environment.

Error
PS C:\Users\FooPath\examples> yarn yarn install v1.19.0 [1/4] Resolving packages... [2/4] Fetching packages... info [email protected]: The platform "win32" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning "eslint-config-bliss > eslint-plugin-jest > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta". [4/4] Building fresh packages... [-/23] ⠐ waiting... [-/23] ⠐ waiting... [-/23] ⠐ waiting... [7/23] ⠈ @amilajack/neon-hello error C:\Users\FooPath\examples\electron-app\node_modules\@amilajack\neon-hello: Command failed. Exit code: 1 Command: npm run build Arguments: Directory: C:\Users\FooPath\examples\electron-app\node_modules\@amilajack\neon-hello Output: > @amilajack/[email protected] build C:\Users\FooPath\examples\electron-app\node_modules\@amilajack\neon-hello > neon build --release

neon info forcing rebuild for new build settings
neon info running cargo
Compiling memchr v2.3.0
Compiling lazy_static v1.4.0
Compiling regex-syntax v0.6.14
Compiling cc v1.0.50
Compiling cfg-if v0.1.10
Compiling semver-parser v0.7.0
Compiling cslice v0.2.0
Compiling neon-build v0.3.3
Compiling thread_local v1.0.1
Compiling semver v0.9.0
Compiling aho-corasick v0.7.7
Compiling regex v1.3.4
Compiling neon-sys v0.3.3
error: failed to run custom build command for neon-sys v0.3.3

Caused by:
process didn't exit successfully: C:\Users\FooPath\examples\electron-app\node_modules\@amilajack\neon-hello\native\target\release\build\neon-sys-3a0909519f5584b3\build-script-build (exit code: 1)
--- stdout
'Skipping node-gyp installation as part of npm install.'
added 96 packages from 70 contributors and audited 96 packages in 3.019s
found 7 vulnerabilities (3 low, 1 moderate, 3 high)
run npm audit fix to fix them, or npm audit for details
cargo:node_arch=x64
cargo:node_root_dir=C:\Users\FooUser\AppData\Local\node-gyp\Cache\14.15.0
cargo:node_lib_file=C:\\Users\\FooUser\\AppData\\Local\\node-gyp\\Cache\\14.15.0\\<(target_arch)\\node.lib

@ build-release C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native
node-gyp build

C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native>if not defined npm_config_node_gyp (node "C:\Users\FooUser\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" build ) else (node "C:\Users\FooUser\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" build )
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: The "GetOutOfDateItems" task failed unexpectedly. [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: System.InvalidOperationException: The item metadata "%(FullPath)" cannot be applied to the path "Release\obj\neon\neon.tlog\ParallelCustomBuild.read.1.tlog". Path: Release\obj\neon\neon.tlog\ParallelCustomBuild.read.1.tlog exceeds the OS max path limit. The fully qualified file name must be less than 260 characters. [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args) [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.Shared.FileUtilities.ItemSpecModifiers.GetItemSpecModifier(String currentDirectory, String itemSpec, String definingProjectEscaped, String modifier, String& fullPath) [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.Utilities.TaskItem.Microsoft.Build.Framework.ITaskItem2.GetMetadataValueEscaped(String metadataName) [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.Utilities.TaskItem.GetMetadata(String metadataName) [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.CPPTasks.GetOutOfDateItems.Execute() [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(186,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() [C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\neon.vcxproj]
TARGET = Some("x86_64-pc-windows-msvc")
HOST = Some("x86_64-pc-windows-msvc")
AR_x86_64-pc-windows-msvc = None
AR_x86_64_pc_windows_msvc = None
HOST_AR = None
AR = None
running: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\lib.exe" "-out:C:\Users\FooUser\Documents\PersonalProjects\NeonHelloWorld\examples\electron-app\node_modules\@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\libneon.a" "-nologo" "C:\Users\FooUser\Documents\PersonalProjects\NeonHelloWorld\examples\electron-app\node_modules\@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\Release\obj\neon\neon.obj"
LINK : fatal error LNK1181: cannot open input file 'C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\Release\obj\neon\neon.obj'
exit code: 1181

--- stderr
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\FooUser\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\FooUser\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build"
gyp ERR! cwd C:\Users\FooPath\examples\electron-app\node_modules@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native
gyp ERR! node -v v14.15.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build-release: node-gyp build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ build-release 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! C:\Users\FooUser\AppData\Roaming\npm-cache_logs\2020-11-09T15_36_34_128Z-debug.log

error occurred: Command "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\lib.exe" "-out:C:\Users\FooUser\Documents\PersonalProjects\NeonHelloWorld\examples\electron-app\node_modules\@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\libneon.a" "-nologo" "C:\Users\FooUser\Documents\PersonalProjects\NeonHelloWorld\examples\electron-app\node_modules\@amilajack\neon-hello\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-6f1054c46a4ce537\out\native\build\Release\obj\neon\neon.obj" with args "lib.exe" did not execute successfully (status code exit code: 1181).

warning: build failed, waiting for other jobs to finish...
error: build failed
neon ERR! cargo build failed

Error: cargo build failed
at Target. (C:\Users\FooPath\examples\electron-app\node_modules\neon-cli\lib\target.js:121:35)
at step (C:\Users\FooPath\examples\electron-app\node_modules\neon-cli\lib\target.js:32:23)
at Object.next (C:\Users\FooPath\examples\electron-app\node_modules\neon-cli\lib\target.js:13:53)
at fulfilled (C:\Users\FooPath\examples\electron-app\node_modules\neon-cli\lib\target.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @amilajack/[email protected] build: neon build --release
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @amilajack/[email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

  • Windows 10
  • cargo 1.47.0 (f3c7e066a 2020-08-28)
  • rustc 1.47.0 (18bf6b4f0 2020-10-07)
  • node-gyp v7.1.2
  • node 14.15.0
  • npm v6.14.8
  • yarn 1.19.0
  • python 3.8.5

I'm seeing node-gyp issues with VS2019 which looks like gyp is trying to use I'll try playing around with different build tools and see if that helps
nodejs/node-gyp#1753

Any tips would be appreciated

The electron example errors out

I just wanted to bring to your attention that the electron-app example doesn't work, and throws an exception. It has a couple of issues:

  1. The npm package "hello-world" has been renamed to "neon-hello" on the npm repo
  2. The "neon-hello" package is not updated on the npm repository (It doesn't match what's in the examples directory)
  3. The neon-cli version in the package.json needs to be updated to 0.3.3 (from the current 0.3.1), otherwise it fails with this error:

image

Question: How to detect primitive type?

I'm trying to convert a js object into serde_json::Value,

First, I got a list of properties via get_own_property_names() and then I enumerator through all properties to get JsValues.

But I don't know how to convert each JsValue into the corresponding rust type, because how can I check the data type of a JsValue?

This is not mentioned in the document.

Thanks.

Generated index.node file size is huge, could it be compressed?

I've cloned and tried the example of tokio-fetch, and the generated index.node file size is 14M, which I think is very large size, is there any way to compress or minimize the size?

total 27984
-rw-r--r--  1 dickeylth  staff   504B Apr 14 12:24 Cargo.toml
-rw-r--r--  1 dickeylth  staff   2.7K Apr 14 12:24 README.md
-rwxr-xr-x  1 dickeylth  staff    14M Apr 14 12:26 index.node
drwxr-xr-x  6 dickeylth  staff   192B Apr 14 12:26 node_modules
-rw-r--r--  1 dickeylth  staff   688B Apr 14 12:24 package.json
drwxr-xr-x  3 dickeylth  staff    96B Apr 14 12:24 src

Add sccache to CI builds

CI builds are fairly slow because of the large number of projects. However, since most projects use the same set of dependencies, sccache should give a significant speed-up.

remove unnecessary metadata from examples

There is a lot of metadata, such as emails and usernames in example package.json's which are not necessary. These should be removed to make the examples more focused and simple

failed to run custom build command for `neon-sys v0.3.3`

I've followed the guide here: https://neon-bindings.com/docs/hello-world

At the last step where neon build --release, it fails with this message.

error: failed to run custom build command for neon-sys v0.3.3

Caused by:
process didn't exit successfully: /mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-0cc2556522515c80/build-script-build (exit code: 1)
--- stdout
added 96 packages from 70 contributors and audited 96 packages in 5.661s
found 7 vulnerabilities (3 low, 1 moderate, 3 high)
run npm audit fix to fix them, or npm audit for details

@ build-debug /mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/native
node-gyp build --debug

TARGET = Some("x86_64-unknown-linux-gnu")
HOST = Some("x86_64-unknown-linux-gnu")
AR_x86_64-unknown-linux-gnu = None
AR_x86_64_unknown_linux_gnu = None
HOST_AR = None
AR = None
running: "ar" "crs" "/mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/libneon.a" "/mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/native/build/Debug/obj.target/neon/src/neon.o"
cargo:warning=ar: /mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/native/build/Debug/obj.target/neon/src/neon.o: No such file or directory
exit code: 1

--- stderr
gyp ERR! build error
gyp ERR! stack Error: not found: make
gyp ERR! stack at getNotFoundError (/mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/which/which.js:13:12)
gyp ERR! stack at F (/mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/which/which.js:68:19)
gyp ERR! stack at E (/mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack at /mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:183:21)
gyp ERR! System Linux 4.19.128-microsoft-standard
gyp ERR! command "/mnt/d/neon/node-v14.15.4-linux-x64/bin/node" "/mnt/d/neon/node-v14.15.4-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--debug"
gyp ERR! cwd /mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/native
gyp ERR! node -v v14.15.4
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build-debug: node-gyp build --debug
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ build-debug 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! /root/.npm/_logs/2021-02-08T01_16_34_723Z-debug.log

error occurred: Command "ar" "crs" "/mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/libneon.a" "/mnt/d/neon/examples-main/hello-world/native/target/debug/build/neon-sys-8c04c05edc17c5e6/out/native/build/Debug/obj.target/neon/src/neon.o" with args "ar" did not execute successfully (status code exit code: 1).

neon ERR! cargo build failed

Error: cargo build failed
at Target. (/mnt/c/Users/honor_station/AppData/Roaming/npm/node_modules/neon-cli/lib/target.js:98:27)
at Generator.next ()
at fulfilled (/mnt/c/Users/honor_station/AppData/Roaming/npm/node_modules/neon-cli/lib/target.js:24:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

Environment:
neon version
0.7.0

ructc --version
rustc 1.47.0

cargo -V
cargo 1.47.0

node --version
v14.15.4

Did not copy "cdylib:my-dependency"

Hi!

Piggybacking on the hello world example by calling a hello world method that is based in my own local package.

my-rust-bindings Cargo.toml

[package]
name = "my-rust-bindings"
version = "0.1.0"
license = "ISC"
edition = "2018"
exclude = ["index.node"]

[lib]
crate-type = ["cdylib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
my-rust = { path = "../my-rust" }

[dependencies.neon]
version = "0.9"
default-features = false
features = ["napi-6"]

my-rust Cargo.toml

[package]
name = "my-rust"
version = "0.1.1"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.4"
// some more ..

[[bin]]
name = "my"
path = "src/main.rs"

[lib]
name = "mylib"
path = "src/lib.rs"

[dependencies.neon]
version = "0.9"
default-features = false
features = ["napi-6"]

my-rust src/lib.rs

use neon::prelude::*;
use mylib::my_module::hello_bm;

#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
    cx.export_function("hello", hello_bm)?;
    Ok(())
}

Running npm run build -- --release --verbose from my my-rust-bindings folder leads to

    Finished release [optimized] target(s) in 2m 24s
Did not copy "cdylib:my-rust"

An index.node is not being created.

Any idea why it has not copied cdylib:my-rust?

Thanks so much!

Apple M1 issue

i've clone this example on both intel chip Mac and M1 chip Mac, and build on both, it works well on intel but got this error on M1, please help me find it out and thanks a lot

image

Fix the broken explains in `Setup` section of `README.md`

Problems:

  1. The different directories
  2. Is undefined the expected result?

Screenshot at the time of this reporting:

image

Details:

1. The different directories
git clone https://github.com/neon-bindings/examples
cd neon-examples

Maybe, the expected fixing is append neon-examples to the tail of the first line. Then it will be work:

git clone https://github.com/neon-bindings/examples neon-examples
cd neon-examples
2. Is undefined the expected result?
# Compile and run an example:
cd primitives
node ./lib/index.js

It will be returns undefined in Arch Linux(WSL 2) and Windows. At least, I gave up to use these examples for my studying NEON using this just as it is. I'll read the sources and debug first before run the example, it is very sadly situation for beginners. 😭

Can't run tokio-fetch example

error[E0282]: type annotations needed
  --> src/fetch.rs:26:10
   |
26 |         .downcast_or_throw::<JsObject, _>(cx)?;
   |          ^^^^^^^^^^^^^^^^^ cannot infer type
   |
   = note: type must be known at this point

error[E0599]: no method named `downcast_or_throw` found for struct `neon::handle::Handle<'_, _>` in the current scope
  --> src/fetch.rs:26:10
   |
26 |         .downcast_or_throw::<JsObject, _>(cx)?;
   |          ^^^^^^^^^^^^^^^^^ method not found in `neon::handle::Handle<'_, _>`
   |
   = note: the method was found for
           - `neon::handle::Handle<'a, T>`

Some errors have detailed explanations: E0282, E0599.
For more information about an error, try `rustc --explain E0282`.

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.