2014-10-30 32 views
11

Tôi đang cố gắng làm cho npm hoạt động trên openshift. Khi tôi cố gắng cài đặt một gói sử dụng npm install:Không thể cài đặt bằng npm vì quyền trong openshift

$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 

Đây là bởi vì tôi không có quyền viết trong thư mục chính của tôi (/var/lib/openshift/5425aaa04******0094/)

Đây là cách NPM cấu hình trông giống như:

$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. 

Vì vậy, tôi đã cố gắng để thiết lập các thiết lập tiền tố:

$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 

Vì tôi không có quyền ghi trong thư mục chính và npm đang cố chỉnh sửa tập tin ~/.npmrc, tôi không thể thay đổi cài đặt.

Bất kỳ ý tưởng nào về cách khắc phục sự cố này? Tất cả tôi muốn làm là có thể cài đặt bower.

Cảm ơn!

EDIT: Tôi không có quyền sudo trong OpenShift

+0

chính xác tôi có cùng một vấn đề, tôi đang đánh giá toàn bộ nền tảng và tôi thiết lập Jenkins trên tài khoản miễn phí. và có sau đó cài đặt gói npm cục bộ là không thể !!! một vấn đề khác là phiên bản nút của tôi là 0.6.x, VERY cũ! và tôi không thể cập nhật nó (hoặc tôi havent tìm thấy giải pháp làm thế nào để làm điều đó). – kamiseq

+0

Bạn không có quyền ghi trong thư mục chính của mình ?? –

+0

Bất kỳ câu trả lời nào không? –

Trả lời

11

Hãy thử điều này:

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

mẹo nhỏ này làm việc cho tôi.

+0

Bạn đặt cái này ở đâu? – leontalbot

2

này làm việc cho tôi

cd nodejs/ 

npm install package 
+0

Điều này thực sự hiệu quả! Thật ngu ngốc khi tôi không nghĩ về nó. – Zaxter

Các vấn đề liên quan