Error: EACCES: permission denied NPM Ubuntu Server - linux

I am running an Ubuntu EC2 server and followed the tutorial provided by AWS to install nvm and node, but when I try to run npm install, I'm thrown an error:
Error: EACCES: permission denied, access '/var/www/app'
Please try running this command again as root/Administrator.
The standard procedure with an EC2 Ubuntu service appears to only provide a ubuntu user with sudo privileges and no access to root so I tried to run sudo npm install, but I receive sudo: npm: command not found. The reason why I believe this is happening is because nvm is located at /home/ubuntu/.nvm/versions/node/v6.12.3/bin/node, which root might not have access to?
Is it possible to point root to the this directory location for this command or is there a different solution?

You're getting that error because you do not have write permission for your user on that /var/www/app.
You can follow the answer here to give permissions to that folder.
https://askubuntu.com/questions/749697/how-do-i-give-myself-access-to-var-www-to-create-and-edit-files-and-folders-in
You are getting the error about npm not being installed when you use sudo because it is not installed for the admin user. I would avoid installing node and npm through sudo though. Just go with changing the folder permissions.

Related

`npm run` giving permission denied

I've started facing an issue today which was not occurring before and no code has been changed on my end.
I'm using Laravel 8 with Laravel Mix and when I run npm run prod I keep getting the following:
> prod
> npm run production
> production
> mix --production
/tmp/production65665869399.sh: 2: mix: Permission denied
Do you have any idea?
I even tried making /tmp directory to have 777 permission and tried to change the owner to be the user I'm logged in as but still the same issue.
It's started all of a sudden and there is no resource about it in the internet.
I'm using Node version 14.15.0 and npm version 8.13.2
This error doesn't occur on my local environment but on AWS Ubuntu server.
Tried to uninstall your node js, and just reinstall it using NVM. Make sure you are not running as root user while installing, hopefully this link can help you:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04

How to give vscode permission to mkdir without using it as sudo su, I'm using mint 20

I recently installed mint and I'm doing some tests on VSCode, I'm a long time windows user but I ran into a problem. I program nodejs and when I run npm install, it gives permission access errors and I want to know if there's a way around it that isn't running vscode as super user.
Error:
npm WARN checkPermissions Missing write access to /home/dotta/Documents/Udemy Codes/surf_shop/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /home/dotta/Documents/Udemy Codes/surf_shop/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/home/dotta/Documents/Udemy Codes/surf_shop/node_modules'
Run the following
ls -la /home/dotta/Documents/Udemy\ Codes/surf_shop you will see that its owned by root, why because you run sudo npm install at some point.
To fix:
Delete node_modules:
sudo rm -rf /home/dotta/Documents/Udemy\ Codes/surf_shop/node_modules
Then fix ownership permissions:
sudo chown dotta:dotta -R /home/dotta/Documents/Udemy\ Codes
Then you will be able to npm install, don't use sudo to install or make directories else when you want to do stuff as a normal user you wont own the directory or file.
Also dont start vs-code as root i.e: sudo code . else any point within vs-code its making folders/files as root.
...
sidenote, avoid spaces in folders or filenames.
you need to give VSCODE admin right,go to VSCODE icon click right button -> properties -> advanced -> grant admin right and close all old terminals on VSCODE ,open a new one and enjoy !

Npm getting permission errors

when I try to globally install any modules, I receive the following error...
[Bot (9)] npm install -g miscord
/home/myhome/nodevenv/Bot/9/bin/npm: line 14: /bin/ln: Permission denied
I can install locally, and from what I understood there is no ln folder or script, additionally, it's not writing the miscord folder or files. I am running Nodejs in an environment where I do not have root permissions however it is setup via CPanel, Nodenv and with ssh access. I have tried a few different modules all giving me the same error.
Try to set your specific permissions for npm sudo npm -g config set user YourUser https://docs.npmjs.com/cli/config.html

yarn error "EACCESS: permission denied, scandir '/home/ubuntu/.config/yarn/link'"

Whenever I try something with yarn on Ubuntu 16.04 server.
It gives an error.
I am currently using nodejs v8.10.0
yarn install v1.5.1
error An unexpected error occurred: "EACCES: permission denied, scandir '/home/ubuntu/.config/yarn/link'".
info If you think this is a bug, please open a bug report with the information provided in "/home/ubuntu/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Anyone know why this is happening?
It's likely a unix permission related problem. There is a solution posted on the dev's github page. Try to run the following command
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
Reference: EACCES: permission denied .config/configstore/bower-github.json #2262
I had this problem as well, I found on another thread that my config folder was owned by root, which created several permissions issues.. I changed owner to my user and this error went away.
See top answer on this thread
Unable to access 'git/attributes'

trying to run "brew uninstall node"

because my npm and node are giving me grief and I want to rinstall them.
Here is the message I get:
Permission denied - /usr/local/Cellar/node/0.10.32/include/node/libplatform/libplatform.h
what's with the Permissions denied?
Sometimes the permissions and/or ownership records can get messed up. Try following the instructions here or running the uninstall again with sudo.

Resources