NativeScript / nx

NativeScript for Nx.
Other
64 stars 17 forks source link

Error: spawn ns ENOENT #14

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.

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 ?

mahmoudajawad commented 3 years ago

I had similar issue the first time I tried this package out, turned out to be some issue with my node installation, where I needed to clean-install node, npm again.

EDIT: Before nuking your current node, consider running the same on another environment.

ReneMueller4P commented 3 years ago

Unfortunately the reinstallation of node and npm did not help. Are there any other ideas to solve the problem

mahmoudajawad commented 3 years ago

Maybe you are hitting similar versions issues like I did with #13 ?

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?

govi2010 commented 3 years ago

@NathanWalker yes we need to use ns.cmd in windows.

I have create PR for to fix this. https://github.com/NativeScript/nx/pull/16

ReneMueller4P commented 3 years ago

Soory for the late answer, I come only tomorrow to test nx in the company, but apparently it has already made @govi2010 . Will also still test it tomorrow.

govi2010 commented 3 years ago

This PR should solve this error.

Currently I modified file in my node_module.

fpaaske commented 3 years ago

Update: Forgive me, I had switched node environment with nvm, so nativescript was not longer available globally.. 🤦‍♂️


I still get this issue on a brand new setup, calling the app nx-test and using angular for ui;

npx create-nx-workspace@latest --cli=nx --preset=empty
cd nx-test
npm install --save-dev @nativescript/nx
npx nx g @nativescript/nx:app hello-world

Then try to run it:

➜  nx-test git:(master) ✗ npx nx run nativescript-hello-world:ios --verbose

> nx run nativescript-hello-world:ios --verbose
events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: spawn ns ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
    at onErrorNT (internal/child_process.js:470: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:274:12)
    at onErrorNT (internal/child_process.js:470:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn ns',
  path: 'ns',
  spawnargs: [ 'debug', 'ios', '--force' ]
}

———————————————————————————————————————————————

>  NX   ERROR  Running target "nativescript-hello-world:ios" failed

  Failed tasks:

  - nativescript-hello-world:ios

  Hint: run the command with --verbose for more details.

I was already running this command with --verbose. Any tips?

marckassay commented 2 years ago

@fpaaske I too used nvm, switched node version, and forgot that nativescript needs to be installed.

I suggest, and for anyone else with that error, that ns package-manager get needs to be executed to ensure that you're using the desired node package manager. Initially, I was using yarn and decided to use npm between switching node versions. If you're using yarn, it also needs to be installed when switching node versions and don't forget to opt-in (or install) for corepack. See here for info on that.