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

Closed
leebaroneau opened this issue Sep 30, 2024 · 20 comments · Fixed by #154 or #158
Closed

Handle platforms that are missing the which command #153

leebaroneau opened this issue Sep 30, 2024 · 20 comments · Fixed by #154 or #158
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
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
@bcomnes
Copy link
Owner

bcomnes commented Oct 18, 2024

Try out https://github.com/bcomnes/npm-run-all2/releases/tag/v6.2.4 and let me know if that works for you.

@leebaroneau
Copy link
Author

Thank you for the update. This is currently what the console is outputing.

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

@bcomnes
Copy link
Owner

bcomnes commented Oct 21, 2024

It shouldn't be cross-spawn'ing which anymore. Are you sure you are running v6.2.4?

@leebaroneau
Copy link
Author

I just uninstalled the package and installed it just to double check the package version and the console output changed.

Console output:

npm-run-all shopify:dev vite:dev
ERROR: Cannot destructure property 'status' of '(intermediate value)' as it is null.

Package.json

{
  "scripts": {
    "dev": "npm-run-all -p -l -r vite:dev shopify:dev",
    "build": "npm-run-all -p -l -r vite:build",
    "shopify:dev": "shopify theme dev --port 9000 --store fa0f41.myshopify.com --live-reload full-page --legacy",
    "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.68.1",
    "@shopify/theme": "^3.57.1",
    "autoprefixer": "^10.4.19",
    "npm-run-all2": "^6.2.4",
    "postcss": "^8.4.38",
    "tailwindcss": "^3.4.1",
    "vite": "^5.2.2",
    "vite-plugin-page-reload": "^0.2.0",
    "vite-plugin-shopify": "^3.0.1"
  }
}

@bcomnes
Copy link
Owner

bcomnes commented Oct 21, 2024

Is there a larger stack trace? Sorry I don't have windows to debug with easily.

@bcomnes
Copy link
Owner

bcomnes commented Oct 21, 2024

Nevermind, I think I see the issue, working on a fix.

@voxpelli
Copy link
Collaborator

@leebaroneau Do you run npm-run-all or npx npm-run-all?

If you don’t prefix it with npx then it will likely use the globally installed version of the package, making it possibly be a mix of two versions here.

npm ls -g npm-run-all2 and npm ls npm-run-all2 can show the installed version of the global and local module respectively.

@voxpelli
Copy link
Collaborator

Is there a larger stack trace? Sorry I don't have windows to debug with easily.

@bcomnes I wonder if we should look into the reason for the short stack trace?

@bcomnes
Copy link
Owner

bcomnes commented Oct 21, 2024

I bungled the release a little bit. Try v6.2.6

@leebaroneau
Copy link
Author

Thank you, I just tried it out was it possible to see the outputted text from both commands?

This is the commands side by side but the right hand side commands sometimes crashes so I have to restart it.
Side by side

Using npm-run-all I can only see the first command's output in the console.
image

@voxpelli
Copy link
Collaborator

@leebaroneau if you scroll up on the output of that second one, don’t you see the output of the other one then?

@leebaroneau
Copy link
Author

@voxpelli - No it only shows whatever is the first command.

Ie npm-run-all vite:dev shopify:dev - will only show the vite output
npm-run-all shopify:dev vite:dev - will only show the shopify output

@leebaroneau
Copy link
Author

@voxpelli - No it only shows whatever is the first command.

Ie npm-run-all vite:dev shopify:dev - will only show the vite output npm-run-all shopify:dev vite:dev - will only show the shopify output

After further investigate it doesn't look like it only runs the first command and never runs the second one at all.

@bcomnes
Copy link
Owner

bcomnes commented Oct 28, 2024

Do you have a reproducible example? I have no idea whats going on from the screenshots.

@voxpelli
Copy link
Collaborator

@leebaroneau Then specify explicitly that it should be parallel, -p (was a while since I used this command, I usually just use run-s and run-p)

@leebaroneau
Copy link
Author

Thank you @voxpelli & @bcomnes for all the help! It's all working.

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
3 participants