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

Error: spawn npm ENOENT #52

Closed
szymondlugolecki opened this issue Jan 5, 2023 · 12 comments · Fixed by #96
Closed

Error: spawn npm ENOENT #52

szymondlugolecki opened this issue Jan 5, 2023 · 12 comments · Fixed by #96

Comments

@szymondlugolecki
Copy link

When trying to run npx @cloudflare/next-on-pages I get an error

C:\Users\...\...\project>npx @cloudflare/next-on-pages  
@cloudflare/next-to-pages CLI
⚡️
⚡️ Installing 'vercel' CLI...
⚡️
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', '-D', 'vercel' ]
}

I use
[email protected] and @18.12.0
[email protected]

@Yoinky3000
Copy link
Contributor

I have already created a pr that can fix this issue, waiting for merge, ref #34

@fineshop
Copy link

How can we fix this issue on windows?

@gvatsov
Copy link

gvatsov commented Feb 24, 2023

How can we fix this issue on windows?

I can say that using the @LOLBRUHNICE changes from the quoted PR are working for me on Windows 11.

@surjithctly
Copy link

FYI: I'm still getting same error. Looks like its not fixed. Using latest version. cc: @LOLBRUHNICE @dario-piotrowicz

CleanShot 2023-03-22 at 21 32 26@2x

@Yoinky3000
Copy link
Contributor

FYI: I'm still getting same error. Looks like its not fixed. Using latest version. cc: @LOLBRUHNICE @dario-piotrowicz

CleanShot 2023-03-22 at 21 32 26@2x

looks like you are using the pr I previously created, it was closed already, and my latest pr that was merged only solve spawn npx problem and only use npx as well

@surjithctly
Copy link

I tried adding npx @cloudflare/next-on-pages@latest @latest flag, but did not work.

Which command I should be using to solve this error?

@dario-piotrowicz
Copy link
Member

Hi @surjithctly are you using pnpm?

if so can you delete all pnpm files and try again (just using npx)?

Are you on windows?

@surjithctly
Copy link

Yes. I’m using PNPM.

This issue occurs on cloudflare pages build (not local). I’m on Mac.

@dario-piotrowicz
Copy link
Member

dario-piotrowicz commented Mar 22, 2023

@surjithctly I've just tried with a fresh new Next.js app (repo)

I think there are some possible solutions:

  • remove the pnpm-lock.yaml file (if you want to keep using pnpm locally you could add the file to the gitignore although I don't think it's the best) (f695cc)
  • keep your code exactly as is but change the build command in the dashboard, for example by removing the pnpm-lock.yaml file on the fly:
    Screenshot at 2023-03-22 22-42-37
  • add pnpm as a devDependency (so that the cloudflare builder can find it when needed) (b1ad7a) (this seems the appropriate/cleanest solution to me if you want to keep using pnpm, especially because the previous two solutions don't guarantee you that the same package versions you're using locally are going to be used in production)

Is any of this helpful? 🙂

@surjithctly
Copy link

Thanks @dario-piotrowicz adding pnpm as devDep worked.

But I guess this issue should be opened again, because this app should work without that as well.

@dario-piotrowicz
Copy link
Member

@surjithctly I'm not sure, I think Cloudflare pages doesn't support pnpm out of the box, as you can for example see
in this conversation and this blogpost.

So I think that currently if you tried using pnpm with any Cloudflare pages app you'd hit the same issue (and if that gets fixed on Cloudflare pages then it will work for next-on-pages as well without any change needed here).


Also as you can see from the message, that step comes from the Vercel CLI itself (source) so I think that there isn't much we can do about it on our side anyways.


@GregBrimble do you agree?

@surjithctly
Copy link

In that case I would suggest a graceful exit with an error message instead of unhandled exception. Something like:

Hey you are using pnpm which is not supported and might throw error. to fix add pnpm as devDep or remove pnpm-lock.yaml file. [insert any friendly message]

So people don't have to google a random error and they know exactly what to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants