vuestorefront / vue-storefront

Alokai is a Frontend as a Service solution that simplifies composable commerce. It connects all the technologies needed to build and deploy fast & scalable ecommerce frontends. It guides merchants to deliver exceptional customer experiences quickly and easily.
https://www.alokai.com
MIT License
10.63k stars 2.08k forks source link

[Bug]: CLI generate store throws when Yarn is not installed (Windows) #6905

Open DavidDeSloovere opened 1 year ago

DavidDeSloovere commented 1 year ago

Describe the Bug

CLI throws error when, probably because Yarn is not installed npx @vue-storefront/cli generate store

Current behavior

CLI throws ugly error

Expected behavior

CLI should return a user friendly message that Yarn is required needs to be installed.

Steps to reproduce

don't not have yarn installed

npx @vue-storefront/cli generate store

enter name for project select magento 2 install magento? no

What version of Vue Storefront are you using?

latest cli

What version of Node.js are you using?

16.20.0

What browser (and version) are you using?

-

What operating system (and version) are you using?

Windows

Relevant log output

β—‡  πŸ€“ Do you want to install Magento 2 locally on your computer? (BETA)
β”‚  No
β”‚
β—‡  πŸ™Œ Node.js version is compatible
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:485: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:291:12)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn yarn',
  path: 'yarn',
  spawnargs: [ '-v' ]
}

Able to fix / change the documentation?

Code of Conduct

DavidDeSloovere commented 1 year ago

Also, prerequisites only mention node and not yarn: https://docs.vuestorefront.io/v2/getting-started/installation.html

Sure, scroll down and you'll see yarn, but you get the point πŸ˜‰

skirianov commented 1 year ago

Thanks for reporting this! I will take a look and release a fix for that. I think the issue is that we are checking for yarn even if user doesn't want to select Magento to install locally.

Also, as @DavidDeSloovere mentioned, this is a flaw in docs and we will add Yarn and part of prereq πŸ‘

tqlong1609 commented 1 year ago

I also have this issue, but I have installed yarn and my node version is: 16.13.1 image

skirianov commented 1 year ago

hey @tqlong1609 can you please run this command yarn -v in your terminal?

Most probably this is an issue how we check Yarn version, I'll release a patch asap

DavidDeSloovere commented 1 year ago

Must say that the error peristed after installing yarn. I'm using nvm for Windows, not usre if that matters.

My yarn -v output is

1.22.19
skirianov commented 1 year ago

@DavidDeSloovere thank you! This is 100% something wrong with Windows yarn version check, I'll release an RC CLI version right now, would you be able to check in 10 mins?

DavidDeSloovere commented 1 year ago

Yes, I have some time today to check.

skirianov commented 1 year ago

Hopefully it is fixed, can you please try it out: npx @vue-storefront/cli@rc init

DavidDeSloovere commented 1 year ago

I think there is something wrong. Only have commercetools as an option, and after selecting that the CLI exits. image

skirianov commented 1 year ago

hmmm...I'm trying to figure out what's happening. Npm package is published, but for some reason it is not updated in the registry. Maybe some propagation issues.

skirianov commented 1 year ago

https://status.npmjs.org/ - there was an issue with npm publish service indeed.

Can you please try npx @vue-storefront/cli@4.1.3 init once again? Patch 4.1.3 is released

DavidDeSloovere commented 1 year ago

The yarn error is gone!

But 2 new issues instead :-)

Without installing Magento locally. The .env.example file is actually there. But the command says "rmdir" to remove a directory. image

With installation of Magento locally. Sudo on Windows? image

skirianov commented 1 year ago

@DavidDeSloovere Windows πŸ’€

Are you running this with WSL installed? Unfortunately CLI does not support installation of Magento locally using Windows without WSL (there are so many issues with that =()

I'll make sure to add this error handler in the next patch.

npm registry right now has issues with the npm publish service so publishing takes a lot of time.

Can you please try running the command wihtout Magento 2 local install once again, will it result in the same error? I'll publish a patch meanwhile

skirianov commented 1 year ago

@DavidDeSloovere patch is up, can you please try npx@vue-storefront/cli@4.1.3-rc.2 init

DavidDeSloovere commented 1 year ago

I have WSL installed. Wasn't running it in WSL though. I can run Magento manually, no problem there. But a disclaimer or error handling would improve the experience.

Windows, RC2, magento, no install. Getting 1 step further now. image

skirianov commented 1 year ago

😭 I know what's the issue here.

Apparently, Windows needs to run yarn.cmd command from Node.js not simply yarn like on Linux and MacOS.

rc3 is up

Thanks a lot for helping me out @DavidDeSloovere

npx@vue-storefront/cli@4.1.3-rc.3 init

DavidDeSloovere commented 1 year ago

Yes! πŸš€

Just one typo "configured" and the word "the" that doesn't need to be there.

image

I'll let you close the issue once the final release is out.

skirianov commented 1 year ago

Amazing thanks so much @DavidDeSloovere!! πŸ™Œ

https://www.npmjs.com/package/@vue-storefront/cli/v/4.1.4 - 4.1.4 patch is out

DavidDeSloovere commented 1 year ago

Looks good this πŸ‘ npx@vue-storefront/cli@latest init

DavidDeSloovere commented 1 year ago

@skirianov I think you forgot to fix another yarncall here: https://github.com/vuestorefront/vue-storefront/blob/4e1ff1aea26493574db860b845128a0ec042b448/packages/cli/src/domains/magento2/functions/installDeps.ts#LL18C1-L19C1

skirianov commented 1 year ago

Looking into it @DavidDeSloovere πŸ™

xXWarMachineRoXx commented 9 months ago

in my case it was yarn

Error: spawn yarn ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:485: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:291:12)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn yarn',
  path: 'yarn',
  spawnargs: []

I solved it by running the command manually

I ran

yarn

and then

yarn dev

in your case you would need to check the command that is failing by checking docker logs and manually type that command by docker exec -it bash _yourdockercontainername_

0ManchesterbytheSea0 commented 4 months ago

@skirianov I am still stuck in this problem, my device is windows, magento 2.4.7 is already installed in ubuntu on window and it is working fine, yarn is already installed on window, can anyone help me, what do I need to do to install it in windows