Skip to content

CLI doesn't work if installed via npm #2

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

Closed
jakerdy opened this issue Aug 4, 2023 · 11 comments
Closed

CLI doesn't work if installed via npm #2

jakerdy opened this issue Aug 4, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@jakerdy
Copy link

jakerdy commented Aug 4, 2023

Describe the bug

I am working on windows. I've tried to create new project with CLI, and it failed.

My setup:

  • npm 9.6.7
  • git bash for windows (it comes with git distribution for windows)
  • node 18.17.0

Steps to reproduce the behavior:

  1. Git Bash Here from context menu in a directory with my projects
  2. npm i -g @tinyhttp/cli
  3. tinyhttp new basic my-app
  4. it fails with:
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 1: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 2: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 3: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 4: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 5: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 6: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 7: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 8: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 9: import: command not found
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 11: syntax error near unexpected token `('
C:\Users\JE\AppData\Roaming\npm/node_modules/@tinyhttp/cli/dist/index.js: line 11: `const msg = (m, color) => console.log(colorette[color](m));'

Also, if i try to run tinyhttp new... from cmd of powershell, I got cli index.js opened in default editor for .js files. Is it me, or CLI shouldn't work on Windows?

Expected behavior

It should work as described in tutorial. I want to get working and settuped project to avoid all that ESM hustle...

@jakerdy jakerdy added the bug Something isn't working label Aug 4, 2023
@aarontravass
Copy link
Member

aarontravass commented Aug 4, 2023

Hi @jakerdy , thanks for reporting the issue. I was able to reproduce it on my local windows machine.

Also, if i try to run tinyhttp new... from cmd of powershell, I got cli index.js opened in default editor for .js files

For me, it didn't work in command prompt nor powershell. I'll look into it.

@jakerdy
Copy link
Author

jakerdy commented Aug 4, 2023

More details, i try it on Linux, same result. But, it most likeley not an os issue, it's npm/pnpm.
I removed package that was installed via npm, and reinstall it with pnpm, and it start working as expected.

@jakerdy jakerdy changed the title CLI doesn't work on Windows CLI doesn't work if installed via npm Aug 4, 2023
@talentlessguy
Copy link
Member

talentlessguy commented Aug 4, 2023

This seems related to #1

My guess — the CLI is missing a #!/bin/sh shebang

PR to fix is welcome

@talentlessguy talentlessguy transferred this issue from tinyhttp/tinyhttp Aug 15, 2023
@talentlessguy
Copy link
Member

@jakerdy could you test on latest 1.3.5 please?

@jakerdy
Copy link
Author

jakerdy commented Aug 17, 2023

Well, it's broken in other place now

$ tinyhttp new basic my-app
Creating a new tinyhttp project from basic template in my-app folder ⚡
Fetching template contents ⌛
⠧ Fetching README.md fileundefined:1
# Basic example
^

SyntaxError: Unexpected token # in JSON at position 0
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (C:\Users\Me\AppData\Roaming\npm\node_modules\@tinyhttp\cli\node_modules\undici\lib\fetch\body.js:580:15)
    at successSteps (C:\Users\Me\AppData\Roaming\npm\node_modules\@tinyhttp\cli\node_modules\undici\lib\fetch\body.js:520:23)
    at C:\Users\Me\AppData\Roaming\npm\node_modules\@tinyhttp\cli\node_modules\undici\lib\fetch\util.js:821:56
    at node:internal/process/task_queues:140:7
    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.17.0

@talentlessguy
Copy link
Member

@jakerdy shit, I'm sorry I convert the readme to JSON and that's why it breaks

@talentlessguy
Copy link
Member

will release a patch soon

@talentlessguy
Copy link
Member

@jakerdy could you try please on latest version? sorry for a late response

@jakerdy
Copy link
Author

jakerdy commented Nov 8, 2023

Nope, it still doesn't work.
image

@aarontravass
Copy link
Member

@talentlessguy

@talentlessguy
Copy link
Member

@jakerdy sorry for the delay again - i've published a new version, it should work properly now

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
Development

No branches or pull requests

3 participants