Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle platforms that are missing the which command #153

Open
leebaroneau opened this issue Sep 30, 2024 · 4 comments · May be fixed by #154
Open

Handle platforms that are missing the which command #153

leebaroneau opened this issue Sep 30, 2024 · 4 comments · May be fixed by #154
Assignees
Labels
bug Something isn't working

Comments

@leebaroneau
Copy link

Hi!

Currently I'm getting this error when trying to run Shopify CLI + VITE. I tried to run a single command and it still threw a similar error.

Package.json

{
  "scripts": {
    "shopify:dev": "shopify theme dev --legacy --port 9000 --store fa0f41.myshopify.com --live-reload full-page",
    "shopify:logout": "shopify auth logout",
    "vite:dev": "vite dev",
    "vite:build": "vite build",
    "kill": "Taskkill /IM node.exe /F"
  },
  "type": "module",
  "devDependencies": {
    "@shopify/cli": "^3.67.0",
    "@shopify/theme": "^3",
    "autoprefixer": "^10",
    "daisyui": "^4.12.10",
    "npm-run-all2": "^6.2.3",
    "postcss": "^8",
    "tailwindcss": "^3",
    "vite": "^5.4.3",
    "vite-plugin-page-reload": "^0.2.0",
    "vite-plugin-shopify": "^3.0.1"
  }
}

Error in console after running: npm-run-all shopify:dev vite:dev

node:events:496
      throw er; // Unhandled 'error' event
      ^

Error: spawn which ENOENT
    at notFoundError (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:40:16)
    at cp.emit (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:27:25)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)
Emitted 'error' event on ChildProcess instance at:
    at cp.emit (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:30:37)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12) {
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn which',
  path: 'which',
  spawnargs: []
}

Node.js v20.11.1 

Error after running single command: npm-run-all shopify:dev

node:events:496
      throw er; // Unhandled 'error' event
      ^

Error: spawn which ENOENT
    at notFoundError (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:40:16)
    at cp.emit (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:27:25)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12)
Emitted 'error' event on ChildProcess instance at:
    at cp.emit (C:\Users\lee\AppData\Roaming\npm\node_modules\npm-run-all2\node_modules\cross-spawn\lib\enoent.js:30:37)
    at ChildProcess._handle.onexit (node:internal/child_process:294:12) {
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawn which',
  path: 'which',
  spawnargs: []
}

Node.js v20.11.1
@bcomnes
Copy link
Owner

bcomnes commented Sep 30, 2024

Thanks, probably windows specific bug around yarn/pnpm support paths. I'll some better error handling here.

In the meantime, running this same thing in a a shell that supports the POSIX which command should work.

@voxpelli
Copy link
Collaborator

voxpelli commented Oct 2, 2024

Related line of code:

const { status: pnpmFound, output: pnpmWhichOutput } = await spawn('which', 'pnpm', { silent: true })

Setting --npm-path should avoid this from triggering

@voxpelli voxpelli changed the title Shopify CLI + VITE: Error when running Handle platforms that are missing the which command Oct 2, 2024
@voxpelli
Copy link
Collaborator

voxpelli commented Oct 2, 2024

We can probably swap to https://github.com/npm/node-which instead

@voxpelli voxpelli self-assigned this Oct 2, 2024
voxpelli added a commit that referenced this issue Oct 2, 2024
Version `3.0.1` of `which` is the latest that supports Node 14. Version 4 requires Node 16 and version 5 requires Node 18. So I'm sticking with `3.0.1` to avoid bumping the engines range in this PR.

`which` is built and maintained by `npm`: https://github.com/npm/node-which

And is tested across multiple environments: https://github.com/npm/node-which/blob/b8d11c791296a3baf44703352619621215189b0e/.github/workflows/ci.yml#L54-L65

Fixes #153
@voxpelli voxpelli linked a pull request Oct 2, 2024 that will close this issue
@voxpelli
Copy link
Collaborator

voxpelli commented Oct 2, 2024

PR for above is created at #154

@voxpelli voxpelli added the bug Something isn't working label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants