nstudio / xplat

Cross-platform (xplat) tools for Nx workspaces.
MIT License
367 stars 52 forks source link

Error: spawn ns ENOENT #257

Closed ReneMueller4P closed 3 years ago

ReneMueller4P commented 3 years ago

Hi, I have a problem when compiling applications I get the following error. on my Windows 10 machine., xplat 12 and npm 7.10

events.js:288
      throw er; // Unhandled 'error' event
      ^

Error: spawn ns 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)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn ns',
  path: 'ns',
  spawnargs: [ 'clean' ]

Is there any solution to this ?

NathanWalker commented 3 years ago

This seems relevant: https://stackoverflow.com/questions/43230346/error-spawn-npm-enoent

@ReneMueller4P try this when you can, in your project root and if using VS Code, you can open the builder like this:

code node_modules/@nativescript/nx/src/builders/build/builder.js

If not using VS Code, you can manually open that file in your editor. If using 0.0.4 latest of @nativescript/nx on line 92, you can try some of the options mentioned in the stack overflow post. I don't have a windows machine here to test with but lemme know if you find a combo that helps Windows and we can make an adjustment.

The StackOverflow post mentions spawn on npm however in this case the builder is using spawn with the ns cli. So something similar may be needed on windows for it to recognize the global {N} cli perhaps?

tiagocmachado commented 3 years ago

@NathanWalker I changed according to your suggestion to const child = childProcess.spawn(/^win/.test(process.platform) ? 'ns.cmd' : 'ns', [nsOptions, { cwd: projectCwd, stdio: 'inherit' }]);

Now I'm not getting an error, but the only feedback that I have is: Screenshot 2021-04-28 at 12 27 27

Isn't it supposed to load the emulator and run the app? Running on macBook

dylannnn commented 3 years ago

@ReneMueller4P I resolved the same issue by install nativescript globally and connected my phone to the laptop.

npm install -g nativescript

After you install nativescript, you can try to run: ns doctor ios to verify if the setup was all correct or follow the the instruction to setup for local builds.

NathanWalker commented 3 years ago

This was fixed by the transient dep on @nativescript/nx from this patch release (doing a workspace clean would pull down latest version and fix the above for windows): https://github.com/NativeScript/nx/releases/tag/1.0.4