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
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.
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:
Sometimes, issues can arise from a corrupted npm cache. Clear the cache by running the following command:
Remove the node_modules directory and reinstall the npm packages by executing the following commands:
Instead of running npm start, you can try using npx to start your React Native project. Execute the following command:
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:
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: