Search code examples
reactjsnode.jsnpmgit-bash

`Npm install` failure-- Error: EACCES: permission denied


I am trying to npm install a react application. I am using Windows 10, VS code with Git Bash. I would also add that I can get it working on WSL2 Ubuntu on VS Code just fine. However, for some odd reason I server reloading takes too long (more than 1 minute).

This is why I am trying to use Git Bash: I used NVM to install NPM, and then npm install in the main project directory.

The error message:

npm error Error: EACCES: permission denied, lstat 'C:\Users\Hamza\Desktop\Project\node_modules\.bin\parser'
npm error     at async lstat (node:internal/fs/promises:1023:18)
npm error     at async Promise.all (index 0)
npm error     at async Promise.all (index 0)
npm error     at async Promise.all (index 0)
npm error     at async #createBinLinks (C:\Users\Hamza\.nvm\versions\node\v22.1.0\bin\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\rebuild.js:394:5)`

I've tried reinstalling, directly installing npm without nvm,and following this stackoverflow post to no avail. npm install should work normally and I should be able to run npm start to run the server. I'm hoping someone can guide me on this.


Solution

  • I fixed it. I used command prompt in VS code like @YuvrajM suggested in the comments. Activate Virtual environment:

    virtualenv <environment_name>
    <environment_name>\Scripts\activate
    

    Delete node_modules directory. Then update your node and dependencies and fix any errors:

    npm install
    npm update
    npm audit fix --force
    

    Try to see if it works npm start