`npm run` giving permission denied - node.js

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

Related

cant run electron on win10 ubuntu subsystem

i have a repo for an electron project ive been able to run in ubuntu subsystem before fine, im on a new pc now and having trouble. I already ran npm i, but when I run electron . i get this err:
martin#DESKTOP-URPCCBK:/mnt/c/Users/marti/Documents/projects/electron-upload-manager$ npm start
> drag-and-drop#1.0.0 start /mnt/c/Users/marti/Documents/projects/electron-upload-manager
> electron .
[5094:0907/143024.016724:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox is owned by root and has mode 4755.
so i ran
sudo chown root /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox
and
sudo chmod 4755 /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox
then ran npm start again, and get:
martin#DESKTOP-URPCCBK:/mnt/c/Users/marti/Documents/projects/electron-upload-manager$ npm start
> drag-and-drop#1.0.0 start /mnt/c/Users/marti/Documents/projects/electron-upload-manager
> electron .
[5120:0907/143308.127280:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox is owned by root and has mode 4755.
I did what the error asked, but still got the error? Ive tried removing my node_modules, reinstalling with npm i, running apt-get update, installing electron globally but still am getting this err
You need to enable metadata on DrvFs. Put this in /etc/wsl.conf:
[automount]
options = "metadata"
After this, chmod/chown should work on windows files. See this Microsoft blogpost for more details.
Try this command. It is a work-around:
sudo sysctl kernel.unprivileged_userns_clone=1
ill just run it in command prompt instead, got it working fine there

npm: command not found on amazon ec2 (even though its installed)

We installed NPM and created an AMI
The elastic beanstalk uses that AMI to create an EC2
The Procfile calls a shell script with the content pasted below.
I am getting the error - npm : command not found (when i use the command npm manually, it works, only fails during beanstalk deploy)
Also used the full path for npm(home/ec2-user/.nvm/versions/node/v11.6.0/bin/npm), which results in permission denied
I know its just a minor thing I am missing here, already spent few hours on this.
I tried sourcing my bash profile, which also results in permission denied.
#!/usr/bin/env bash
npm install
npm install -g serve
npm run build
nohup serve -s build > orgweb.log &
Not sure if it is just a typo or did you use this exact full path
home/ec2-user/.nvm/versions/node/v11.6.0/bin/npm
But if you did, there needs to be a slash before home, as in
/home/ec2-user/.nvm/versions/node/v11.6.0/bin/npm

'npm EER! code 1' When installing dependencies using `npm install --production`

I am using flightplan to deploy my node.js application to my server. I run the command fly production in my CLI to deploy my app to the server. It does rsync fine, but when it comes to installing dependencies, I get the following error:
I made sure that I have sudo privileges on my server for this user and npm is definitely installed as it gives the version number when I run the command npm -von my server. I have tried to run npm install --production myself on the server as the deploy script does and I get the same error, meaning it is something to do with installing dependencies. Potentially, it could be because in my flightplan.js, when it runs the command git ls-files to get the files to copy across. it includes all the node_modules even though i've made sure that node_modules is in the .gitingore file.
Does anyone have experience with flightplan npm module/or know why my npm install isn't working on my server?
(I edited out my server IP address from the picture)
Thanks in advance!
I found that if I removed the node_modules folder by running command rm -rf node_modules/ then committed this to github, then re-ran npm install and then my call to fly production worked successfully.

npm install throws error after a fresh install of node modules

After upgrading my node to v 4.2 , executed npm install for my node project as a root user from my home directory and it is successful. But started throwing module not found or can not find js file errors including binding exception while starting my app.
You solved your problem.
Because installing application without superuser permission prevent the other dependencies to be installed.
I recommend to enter to super user / root by sudo su - when installing.
Run 'sudo npm install' to avoid exceptions and it creates node_modules directory with current user. This solved my problem.

Permissions Denied in Terminal

So I am a little new to working in the terminal and trying to set up yo and a localhost environment. No matter what I do it keeps throwing a permissions denied error. I have installed node and npm already and when I run the yo install
npm install -g yo bower grunt-cli gulp i get this error message. My buddy and I have tried so many different things to fix this but we cant get anywhere. I can access and run using sudo but I need to actually have the permissions to get this working. Help please?
I am sorry if that is not detailed enough, I am new to working in the terminal and may not know entirely what I am doing. If all else fails I was going to reset my desktop to factory settings and start over with setting my users and groups.
Screenshot of errors Here
sudo chown -R `whoami` /usr/local
or
npm install npm -g
...will do the trick.
You're not the first one to experience those problems and they are (finally) actively addressed in npm#3.X.X

Resources