antfu-collective / ni

💡 Use the right package manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prompt the user if it is not currently a valid node project

wChenonly opened this issue · comments

Clear and concise description of the problem

Now if you run in an arbitrary empty folder, executing ni will report an error that is not friendly, and executing other will not receive feedback. not very friendly

image

Suggested solution

In the runCli method, first determine whether there is package.json file, and if so, continue.
If not, prompt the user that this directory is not a valid project.

Or prompt the user if you want to create a new project, we execute. npm init

I can add this if I can.

Alternative

No response

Additional context

No response

Validations

image

This is the error printed by npm i. It's npm's reusability to make it more readable, and I don't think ni should do anything about it.