neon-bindings / examples

A collection of examples of Neon
324 stars 43 forks source link

electron-example fails on npm run build #58

Closed Stromberg90 closed 2 years ago

Stromberg90 commented 4 years ago

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! electron-quick-start@1.0.0 build: `electron-build-env neon build neon-hello --release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-quick-start@1.0.0 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"
}
amilajack commented 4 years ago

Do you have cargo installed?

Stromberg90 commented 4 years ago

I do, I have very little node.js and electron experience, so I could be messing up something in that area.

❯ cargo --version
cargo 1.43.0 (2cbe9048e 2020-05-03)
❯ rustc --version
rustc 1.43.1 (8d69840ab 2020-05-04)
therocode commented 4 years ago

I am also experiencing this. I am also on windows 10, and following the examples, trying to build a simple neon dependency.

I have cargo's bin folder in my PATH, all terminals recognise cargo. I can also run "neon build" in the neon dependency folder and it launches cargo and builds successfully. However, being in another node project, that USES the neon dependency, trying to build it through electron-build-env by doing npm run-script build with a script like "build": "electron-build-env neon build ../web-source --release" where web-source is the neon dependency, I get:

$ npm run-script build

> inspector@1.0.0 build C:\projects\rustectron\inspector
> electron-build-env neon build ../web-source --release

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! inspector@1.0.0 build: `electron-build-env neon build ../web-source --release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the inspector@1.0.0 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\widlu\AppData\Roaming\npm-cache\_logs\2020-06-27T07_55_16_435Z-debug.log

it's as if electron-build-env is not finding cargo, even though the rest of my system consistently does.

therocode commented 4 years ago

I solved it for me actually. The problem arises when the path given to build is not correct. For example, by using the neon dependency from the example: "electron-build-env neon build @amilajack/neon-hello --release" even just adding a typo here like build @amilajack/neon-hlelo triggers the above error. So it's a bit of a misleading error that makes it look like cargo can't be spawned.

kjvalencik commented 2 years ago

This example has been deprecated and the Node-API backend (default now) does not require electron-build-env. Neon modules work out of the box in Electron.