我想让npm在openshift上工作。当我尝试使用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
这是因为我没有权限在我的主目录中写入(/var/lib/openshift/5425aaa04******0094/
)
这是npm配置的样子:
$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.
所以我尝试设置前缀设置:
$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
由于我在主目录中没有写入权限,而npm正在尝试编辑〜/ .npmrc文件,我无法更改设置。
关于如何解决此问题的任何想法?我想做的就是能够安装凉亭。
谢谢!
编辑:我在openshift中没有sudo权限答案 0 :(得分:11)
试试这个:
OLDHOME=$HOME
HOME=`pwd`
npm install package
HOME=$OLDHOME
这个小技巧对我有用。
答案 1 :(得分:2)
这对我有用
<span class="brand">carlos santos</span>