QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.83k stars 1.31k forks source link

[🐞] qwik new component Error #5321

Closed l6037600 closed 1 year ago

l6037600 commented 1 year ago

Which component is affected?

Starters / CLI

Describe the bug

In Utilities section on project structure page, it says by running this command:

pnpm qwik new button

It throws an error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

I checked the source code. In my local running environment, (cli.cjs)at line 3034template.relative is undefined.

when i specify template.relative value, A new error has appeared:

(cli.cjs)at line 3049: await import_node_fs7.default.promises.writeFile(fileOutput, templateOut, { encoding: "utf-8" });
Error: EISDIR: illegal operation on a directory, open 'D:\xxx\qwik-xxx\src\components\button'

Then I modified the code from fileOutput to ${fileOutput}/index.tsx and the error disappeared. I also tried changing the dependency package version I don’t know if it’s due to my local operating environment, incompatible versions of dependent packages, or other reasons

Reproduction

https://github.com/l6037600/qwik-cli-new-component-error

Steps to reproduce

Run pnpm qwik new button

System Info

System:
    OS: Windows 11
    CPU: Intel(R) Core(TM)
    Memory: 6.00 GB / 12.00 GB
    Shell: PowerShell
  Binaries:
    Node: 20.8.1 - C:\Program Files\nodejs\node.exe
    npm: 8.19.2 - C:\Users\Administrator\AppData\Roaming\npm
    pnpm: 8.9.2 - C:\Users\Administrator\AppData\Roaming\pnpm
  Browsers:
    Edge: 118.0.2088.46
  npmPackages:
    @builder.io/qwik: 1.2.13
    @builder.io/qwik-city: 1.2.13
    undici: 5.22.1
    vite: 4.4.7

Additional Information

No response

mhevery commented 1 year ago

I am unable to reproduce this on a clean npm create qwik@latest or by cloning the repro provided. Need better repro instructions. Maybe windows only issue?

Neschadin commented 1 year ago

I am unable to reproduce this

hi! i have the same problem

pnpm qwik new my-button image

https://github.com/Neschadin/qwik-empty

gioboa commented 1 year ago

@Neschadin can you try with Qwik 1.2.15 pls?

l6037600 commented 1 year ago

@Neschadin您可以尝试使用 Qwik 1.2.15 吗?

I still get the same error

alex-bluetrain commented 1 year ago

I have the same error, the problem seems to be at parseTemplatePath in qwil/cli.cjs

the "relative" attribute is undefined, because the split fails. I changed it to this, and it works:

function parseTemplatePath(path3, type) {
  // const parts = path3.split(`/${type}/`);
  const parts = path3.split(type);
  return {
    absolute: path3,
    relative: parts[1]
  };
}
Neschadin commented 1 year ago

@Neschadin can you try with Qwik 1.2.15 pls?

the same image

thejackshelton commented 1 year ago

@Neschadin this happens with pnpm only?

Neschadin commented 1 year ago

@Neschadin this happens with pnpm only?

yeap

gioboa commented 1 year ago

@alex-bluetrain you found the right place to modify. Would you like to drop a PR for that pls?