Things I want to do
When I ran the npm/npx command, I received the error errno -4058 and it failed.
in particular
npx create-next-app@latestThe following error was displayed when I ran it:
npm error code ENOENT
npm error syscall lstat
npm error path C:\Users\XXXXXXXXX\AppData\Roaming\npm
npm error errno -4058
npm error enoent ENOENT: no such file or directory, lstat 'C:\Users\XXXXXXXXX\AppData\Roaming\npm'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: C:\Users\XXXXXXXXX\AppData\Local\npm-cache\_logs\2024-09-22T06_50_41_859Z-debug-0.logXXXXXXXXX is the username.
Solution
Here are two solutions.
Doing just one thing won’t necessarily solve the problem, so if one method doesn’t work, you should try both.
Terminate the application running the Node.js server.
It seems that applications running the Node.js server (applications that execute commands like `npm run dev`) can sometimes interfere.
Examples include Command Prompt, PowerShell, and Visual Studio Code.
First, close these applications and then run the failed npm/npx again.
Installing npx
Install npx by running the following command from the command line or similar.
npm i -g npxRun the failed npm/npx again.
Even if npx is available in other projects, it cannot be used in projects other than the one in which it was installed unless it was installed with the -g option.
Therefore, even if you have successfully executed npx before, it’s a good idea to try it again.
Result
In my environment, simply closing Visual Studio Code didn’t solve the problem; I had to install npx afterward to resolve it.
Websites I used as references



コメント