honojs / create-hono

CLI for creating a Hono app
41 stars 12 forks source link

npm run deploy: "$npm_execpath" isn't recognized as an internal or external command, program, or executable batch file #52

Open axww opened 2 weeks ago

axww commented 2 weeks ago

What version of Hono are you using?

4.4.7

What runtime/platform is your app running on?

Windows, Node.js v22.3.0

What steps can reproduce the bug?

Hi, it's the Windows guy again.

When I run npm run deploy, it shows error: _"$npmexecpath" isn't recognized as an internal or external command, program, or executable batch file

According to: https://stackoverflow.com/questions/53883405/npm-execpath-isnt-recognized-as-an-internal-or-external-command-program-or

I changed from: "deploy": "$npm_execpath run build && wrangler pages deploy" to: "deploy": "npm run build && wrangler pages deploy"

Then the problem solved. Is there a solution which compatible both Windows and Linux?

Thank you Best

yusukebe commented 2 weeks ago

Hi @axww

Thank you for creating the issue. This is a create-hono matter, so I've transferred.

@6km @ryuapp @goisaki

I think we can avoid this issue if we make the create-hono change $npm_execpath to the proper package manager command. What do you think of this?

goisaki commented 2 weeks ago

Hi @yusukebe, @axww I think it's good. Can I create a solution PR?

ryuapp commented 2 weeks ago

I think we can avoid this issue if we make the create-hono change $npm_execpath to the proper package manager command. What do you think of this?

Sounds nice, but in my opinion, I don't need the build command in deploy alias. Even in Cloudflare docs, the deploy alias does not include a build command. https://developers.cloudflare.com/workers/wrangler/commands/#how-to-run-wrangler-commands

If you would like to include a build command, it would be good if we could control it with create-hono as you intended.

yusukebe commented 2 weeks ago

@ryuapp

Sounds nice, but in my opinion, I don't need the build command in deploy alias.

You may be right. This is kind of a personal taste. I like to include the build command in the deploy command so I don't forget to build.

yusukebe commented 1 week ago

@goisaki

I think it's good. Can I create a solution PR?

Can you work on this?

6km commented 1 week ago

Hi @yusukebe! I was busy for the last a few days.

The problem is that the syntax of environment variables is different on each platforms. For example, It's %VARIABLE% on Windows, but it's $VARIABLE on Unix.

A Stack Overflow answer suggests using yarpm to deal with the difference of package managers when using run scripts. I guess it's a good way to deal with this issue, but is there a way to deal with it without using external packages?

EDIT: I just found out that yarpm can't detect bun.

yusukebe commented 1 week ago

Hi @6km

Thank you for the information. Hmm, suppose we'll have to replace $npm_execpath after all.