j-d-carmichael / boats

Beautiful Open Api Template System
MIT License
57 stars 8 forks source link

Error: spawn npm ENOENT #74

Closed WoobaWooba closed 1 year ago

WoobaWooba commented 2 years ago

Describe the bug I followed the Getting Started and tried to run the demo but got the spawn npm enoent error.

To Reproduce

  1. Created an npm project with npm init
  2. Ran the command npm i boats on the same project as I ran the npm init command
  3. Added the scripts and dependencies to the Package.json file:
    "scripts": {
    "boats": "boats",
    "build:json": "boats -i ./src/index.yml -o ./build/awesome-api-d.json",
    "build:yaml": "boats -i ./src/index.yml -o ./build/awesome-api-d.yml",
    "build": "npm run build:json && npm run build:yaml"
    },
    "dependencies": {
    "boats": "latest"
    }
  4. Ran the command npm run boats -- --init
  5. The options menu appeared. I chose to use the same name as in the package.json file, then chose OpenAPI3.0.0 (although the other two options also reproduced the same error) and pressed "y"
  6. This error message appeared:
    
    Completed: Injected a .boatsrc file
    Completed: Installed boats skeleton files to C:/Users/User/Desktop/dsl/boats_test2/src
    Completed: Created a build output directory
    Completed: BOATS build scripts added to your package.json
    node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn npm', path: 'npm', spawnargs: [ 'install' ] }


**Expected behavior**
Run without any errors.

**Additional context**
Here's the full console log of `npm run boats -- --init`:

PS C:\Users\User\Desktop\openapi\dsl\boats_test2> npm run boats -- --init

boats_test2@1.0.0 boats boats "--init"

Checking version from npm api (ꙨပꙨ) This local version looks fresh and shiny, nice! ? Enter the name of the api file, press enter to use the current package.json name attribute: boats_test2 ? oaType: OpenAPI 3.0.0 ? Press Y and enter to install. This will make a copy of the template files to ./src, an output directory ./build and a config file ./.boatsrc Yes Completed: Injected a .boatsrc file Completed: Installed boats skeleton files to C:/Users/User/Desktop/openapi/dsl/boats_test2/src Completed: Created a build output directory Completed: BOATS build scripts added to your package.json node:events:368 throw er; // Unhandled 'error' event ^

Error: spawn npm ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn npm', path: 'npm', spawnargs: [ 'install' ] }

j-d-carmichael commented 2 years ago

@WoobaWooba - Which version of node and windows are you running?

WoobaWooba commented 2 years ago

I'm running node.js version 16.13.2 on windows 10

p-mcgowan commented 2 years ago

Seems to be having trouble finding npm: spawn npm ENOENT at init line 16.

Based on this SO post, seems like a windows thing not being able to find npm.

j-d-carmichael commented 2 years ago

Oh nice find @p-mcgowan

I'll spin up windows and give this a whirl at some point this week.

Unless you have not already @WoobaWooba you can also do what the cli-script does by hand, create the scripts in your package.json file and copy out the example files from https://github.com/j-d-carmichael/boats/tree/main/srcOA3 to your local src directory. However reading the error logs it looks like this already got done by the cli script.

j-d-carmichael commented 1 year ago

resolved on 2.39.0