skip to Main Content

I have had a code of react native. I installed the npm pacakges and when I run npm start it says permission denied. I tried to change ownership using sudo chown linux: node_modules/.bin/**. But it also didn’t work. I tried to start being root that also didn’t work.
The error is like this.

linux@linux ~/quiz $ npm start

> [email protected] start
> expo start

sh: line 1: /home/linux/quiz/node_modules/.bin/expo: Permission denied

My OS: Endeavour OS (Arch based)

How can I solve this problem ?

2

Answers


  1. Chosen as BEST ANSWER

    I had got that project from a friend who was running widows. I think that was the problem. When I fresh start the project form scratch in my system it worked.


  2. Few things to try out.

    Check the permissions of the node_modules directory and its contents to ensure that the user running the command has the necessary permissions. Navigate to the project directory and run the following command to set the correct ownership and permissions:

    sudo chown -R $(whoami) node_modules/
    

    Sometimes, issues can arise from a corrupted npm cache. Clear the cache by running the following command:

    npm cache clean --force
    

    Remove the node_modules directory and reinstall the npm packages by executing the following commands:

    rm -rf node_modules/
    npm install
    

    Instead of running npm start, you can try using npx to start your React Native project. Execute the following command:

    npx expo start
    

    Ensure that you are using the latest versions of npm and Node.js. Update them to their latest stable versions by running the following commands:

    npm install -g npm
    nvm install stable (if you use Node Version Manager - NVM)
    

    If all else fails, you can try running the command with elevated privileges using sudo. However, it’s generally recommended to avoid using sudo with npm commands. If you choose to proceed with sudo, use the following command:

    sudo npm start
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search