Context:
Issue occurs when attempting to create a React app using below command in a custom directory where Node.js and npm are installed.
npx create-react-app my-frontend-app --template typescript
Platform:
Windows 10
Issue:
Below errors occur when npm not being able to find the default directory due to the custom installation path.
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\usernmae\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\usernmae\AppData\Roaming\npm'
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\usernmae\AppData\Local\npm-cache_logs\2023-09-27T01_59_25_928Z-debug-0.log
Solution:
- Open a command prompt as an administrator by right-clicking on the Command Prompt icon and selecting "Run as administrator".
- Navigate to the directory where Node.js and npm are installed using the cd command. For example:
cd D:\Installations\nodejs - Reinstall npm using the following command to ensure you have the latest version:
npm install -g npm@latest
This command will install the latest version of npm globally on your system. - Verify the npm version to confirm the successful installation:
npm -v
This command should display the version number of npm without any errors. - If the issue persists, consider completely uninstalling Node.js and npm, removing related directories, and then reinstalling them using the official installer from the Node.js website.
If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged
No comments:
Write comments