Reputation: 1813
I am trying to deploy an app on my server with pm2. When i try to deploy it i have a some permissions issues.
For exemple i can not install something with npm
globaly, i can not run an apt-get install
, and it can't even run the "path"
which should create the 'workdir' of the project...
Here is my config with blank infos :
{
"apps": [
{
"name": "app",
"script": "scripts/start.js"
}
],
"deploy": {
"production": {
"user": "namedUser",
"host": ["**.**.**.**"],
"ref": "origin/master",
"repo": "[email protected]:***",
"path": "/var/www/production",
"pre-setup": "sudo apt-get install git nodejs npm; npm i -g yarn; yarn",
"post-setup": "ls -la",
"post-deploy": "yarn start"
}
}
}
But pm2 can't execute any of thes.
When i try to install something in the "pre-setup"
i get this error from npm (event with a sudo) :
checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! Linux 4.15.0-22-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "-g" "yarn"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/yarn
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/yarn'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/yarn'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules/yarn' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
And when i remove everythings i want to install except the "path"
i get this :
mkdir: cannot create directory '/var/www': Permission denied
Upvotes: 1
Views: 5935
Reputation: 502
You need to add you user to the sudo group to make it able to use "sudo".
# usermod -aG sudo username
You need to make the user the owner or in the owner group of "/var/www".
# chown username /var/www/
and you need to fix npm permissions to be able to install packages globally.
Upvotes: 2