ui icon indicating copy to clipboard operation
ui copied to clipboard

ENOENT error when installing component with npx shadcn-ui@latest

Open renanleonel opened this issue 2 years ago • 5 comments

i tried to install the 'Toast' component using the command in the documentation 'npx shadcn-ui@latest add toast', and received the following error:

npx shadcn-ui@latest add toast npm ERR! code ENOENT npm ERR! syscall lstat npm ERR! path C:\Users\renan\AppData\Roaming\npm npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\...\AppData\Roaming\npm' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent

after deleting the 'node_modules' folder, '.next', and the 'package-lock.json' file and reinstalling everything, I found that the error was due to the '@latest' flag. running the command 'npx shadcn-ui add toast' instead of 'npx shadcn-ui@latest add toast' as stated in the documentation solved my problem.

https://ui.shadcn.com/docs/components/toast

renanleonel avatar Sep 19 '23 19:09 renanleonel

I met same the problem, thanks for solution.

jaosn60810 avatar Sep 23 '23 02:09 jaosn60810

add the component manually

mstf1985 avatar Oct 04 '23 07:10 mstf1985

ENOENT error when installing component with npx shadcn-ui@latest

npx shadcn-ui@latest add button
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\renan\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\...\AppData\Roaming\npm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoen

i was getting the same error and removing the @lastest did not help , i was using zsh in terminal , I solved the problem by switching to the bash terminal

samima55 avatar Oct 20 '23 10:10 samima55

I had been getting the same error. I solve it as follow create npm directory on %Appdata% works on me

Sambod50 avatar Nov 04 '23 11:11 Sambod50

I faced the same error on a new Windows dev machine when running command npx shadcn-ui init@latest and receiving no such file or directory, lstat 'C:\Users\...\AppData\Roaming\npm'

Since the error says the directory is missing, I created the directory with command mkdir 'C:\Users\...\AppData\Roaming\npm' in addition to removing @latest from the initial command.

hsellik avatar Nov 11 '23 08:11 hsellik

All solutions, including the one proposed by @hsellik didn't work for me. Only managed to start the installation, but after pressing y I got the error

Error: package.json: ENOENT: no such file or directory, open 'C:\Users...\AppData\Roaming\package.json'

LironCareto avatar Feb 11 '24 09:02 LironCareto

@hsellik thanks! The solution works fine for me. In my case, after created a directory npm in C:\Users\....AppData\Roaming I was able to keep using @latest

LucasMagaldi avatar Feb 21 '24 01:02 LucasMagaldi

Also had this issue but npx shadcn-ui@latest init fixed it

jlioanag avatar Mar 04 '24 23:03 jlioanag

I had the same problem when trying to install the Tabs component. I solved it by running 'mkdir C:\Users...\AppData\Roaming\npm' and then installed the component as recommended in the documentation: 'npx shadcn-ui@latest add tabs'

den-gu avatar Mar 11 '24 08:03 den-gu

it works without using the latest

c-ent avatar May 07 '24 06:05 c-ent

If you are using Linux, it may help you:

npm install -g npm

claudsondouglas avatar May 18 '24 19:05 claudsondouglas