gpt4 book ai didi

npm - 无法使用 npm 安装,因为 openshift 中的权限

转载 作者:行者123 更新时间:2023-12-04 00:58:31 25 4
gpt4 key购买 nike

我正在尝试让 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,因此我无法更改设置。

关于如何解决这个问题的任何想法?我想要做的就是能够安装 bower 。

谢谢!

编辑:我在 openshift 中没有 sudo 权限

最佳答案

试试这个:

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

这个小技巧对我有用。

关于npm - 无法使用 npm 安装,因为 openshift 中的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26661978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com