Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install using npm because permissions in openshift

I am trying to make npm working on openshift. When I try to install a package using npm install :

$npm install bower
npm ERR! Error: EACCES, mkdir '/var/lib/openshift/5425aaa04******0094/.npm'
npm ERR!  { [Error: EACCES, mkdir '/var/lib/openshift/5425aaa04******0094/.npm']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/var/lib/openshift/5425aaa04******0094/.npm' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 2.6.32-431.29.2.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "bower"
npm ERR! cwd /var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! path /var/lib/openshift/5425aaa04******0094/.npm
npm ERR! code EACCES
npm ERR! message EACCES, mkdir '/var/lib/openshift/5425aaa04******0094/.npm'
npm ERR! errno 3
npm ERR! 3 errno
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 3

This is because I don't have permissions to write in my home directory (/var/lib/openshift/5425aaa04******0094/)

This is how npm config looks like:

$npm config list
; cli configs

; node install prefix = undefined
; node bin location = /usr/bin/node
; cwd = /var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies
; HOME = /var/lib/openshift/5425aaa04******0094/
; 'npm config ls -l' to show all defaults.

So I tried to set the prefix setting:

$npm config set prefix /var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies/
npm ERR! Error: EACCES, open '/var/lib/openshift/5425aaa04******0094/.npmrc'
npm ERR!  { [Error: EACCES, open '/var/lib/openshift/5425aaa04******0094/.npmrc']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/var/lib/openshift/5425aaa04******0094/.npmrc' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 2.6.32-431.29.2.el6.x86_64
npm ERR! command "node" "/usr/bin/npm" "config" "set" "prefix" "/var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies/"
npm ERR! cwd /var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! path /var/lib/openshift/5425aaa04******0094/.npmrc
npm ERR! code EACCES
npm ERR! message EACCES, open '/var/lib/openshift/5425aaa04******0094/.npmrc'
npm ERR! errno 3
npm ERR! 3 errno
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /var/lib/openshift/5425aaa04******0094/app-root/runtime/dependencies/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 3

As I don't have write permissions in my home directory and npm is trying to edit the file ~/.npmrc, I can't change the settings.

Any ideas on how can I fix this? All I want to do is being able to install bower.

Thanks!

EDIT: I don't have sudo permissions in openshift

like image 411
mario595 Avatar asked Oct 30 '14 19:10

mario595


People also ask

How do I force an NPM package to install?

The -f or --force argument will force npm to fetch remote resources even if a local copy exists on disk. The -g or --global argument will cause npm to install the package globally rather than locally.


2 Answers

this worked for me

cd nodejs/

npm install package
like image 25
PSVapour Avatar answered Sep 20 '22 13:09

PSVapour


Try this :

OLDHOME=$HOME
HOME=`pwd`
npm install package
HOME=$OLDHOME

This little trick works for me.

like image 63
laobubu Avatar answered Sep 16 '22 13:09

laobubu