Search code examples
javascriptreactjsnode.jsnext.js

Error in Installing NextJs/ReactJs npm ERR! errno -4058, no such file or directory, lstat 'D:\usr'


I have update my window(through 11 Disk Image (ISO)) after that I'm unable to work with NextJS or ReactJs.

PS D:\Presonal Proj\Fullstack> node -v
v18.18.2
9.8.1
PS D:\Presonal Proj\Fullstack> npx create-next-app@latest
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path D:\usr
**npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'D:\usr'**
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\user_name\AppData\Local\npm-cache\_logs\2023-10-18T21_03_27_599Z-debug-0.log


how to install NextJs or ReactJs in Window


Solution

  • The issue is likely caused by the prefix setting in your npm configuration. It appears that the prefix is set to "D:\usr\local" in your user-specific .npmrc configuration, which is causing npm to look for directories in that location.

    To resolve this issue, you should reset the prefix value to its default. You can do this by running the following command:

    npm config set prefix "C:\\Users\\user_name\\AppData\\Roaming\\npm"
    

    This will set the prefix back to the default location, which should be under your user's home directory.