热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

当我执行npminstall时,GitClone的权限被拒绝-PermissiondeniedforGitClonewhenIdonpminstall

Ihavegitdependenciesinmypackage.jsonfile.WhenIdosudonpminstallinmyreactappfolder,

I have git dependencies in my package.json file. When I do sudo npm install in my react app folder, I get this error

我的package.json文件中有git依赖项。当我在我的react app文件夹中执行sudo npm install时,我收到此错误

    npm ERR! code 1
    npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master 
    https://github.com/lrojas94/react-file-base64.git /home/admin1/.npm/_cacache/tmp/git-clone-462782fb
    npm ERR! /home/admin1/.npm/_cacache/tmp/git-clone-462782fb/.git: Permission denied
    npm ERR! 

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/admin1/.npm/_logs/2017-07-18T08_58_10_906Z-debug.log
    admin1@ubuntu:~/hys_pms/ui$ nohup: appending output to ‘nohup.out’

This is my package.json

这是我的package.json

    {
      "name": "react-hys-app",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "annogenerate": "^0.8.1",
        "bootstrap": "^3.3.7",
        "cors-prefetch-middleware": "^1.0.0",
        "es6-promise": "^4.1.0",
        "express": "^4.15.3",
        "fixed-data-table": "^0.6.4",
        "flexbox-react": "^4.4.0",
        "font-awesome": "^4.7.0",
        "images-upload-middleware": "^1.1.1",
        "isomorphic-fetch": "^2.2.1",
        "jquery": "^3.2.1",
        "react": "^15.3.1",
        "react-autosuggest": "^9.0.1",
        "react-avatar-cropper": "^0.1.3",
        "react-bootstrap": "^0.30.8",
        "react-bootstrap-autosuggest": "^0.5.0",
        "react-bootstrap-date-picker": "^5.0.1",
        "react-bootstrap-table": "^3.3.1",
        "react-checkbox-list": "0.0.2",
        "react-datepicker": "^0.51.0",
        "react-datetime": "^2.8.10",
        "react-dom": "^15.4.0",
        "react-dual-listbox": "^1.1.0",
        "react-edit": "^6.3.0",
        "react-file-base64": "git+https://github.com/lrojas94/react-file-base64.git",
        "react-flexbox-grid": "^1.1.3",
        "react-grid-layout": "^0.14.6",
        "react-images-uploader": "^1.0.1",
        "react-pagify": "^2.2.0",
        "react-panelgroup": "^1.0.2",
        "react-radio-button-group": "^1.2.5",
        "react-redux": "^5.0.4",
        "react-router": "^2.7.0",
        "react-s-alert": "^1.3.0",
        "react-select": "^1.0.0-rc.5",
        "react-visibility-toggles": "^1.1.1",
        "reactabular-resizable": "^8.9.0",
        "reactabular-table": "^8.9.0",
        "recompose": "^0.23.5",
        "redux": "^3.6.0",
        "redux-devtools-extension": "^2.13.0",
        "redux-thunk": "^2.2.0",
        "redux-undo": "^1.0.0-beta9-9-1",
        "reflexbox": "^3.0.0-0",
        "schema2object": "^0.4.0",
        "searchtabular": "^1.5.0",
        "segmentize": "^0.4.1",
        "sortabular": "^1.4.0",
        "table-resolver": "^3.1.0"
      },
      "devDependencies": {
        "css-loader": "^0.28.4",
        "react-scripts": "0.9.5",
        "style-loader": "^0.18.2"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      }
    }

This line in package.json makes the issue.

package.json中的这一行引发了这个问题。

"react-file-base64": "git+https://github.com/lrojas94/react-file-base64.git"

I am struck with this issue. Kindly help.

我很震惊这个问题。请帮助。

3 个解决方案

#1


1  

I don't know whether your problem is solved or not. Today i faced the same issue the problem was ~/.npm folder is messing with permission so I changed permission as sudo chown -R $(whoami) ~/.npm and it is working fine.

我不知道你的问题是否得到了解决。今天我遇到了同样的问题,问题是〜/ .npm文件夹弄乱了权限所以我改变了权限,因为sudo chown -R $(whoami)〜/ .npm并且它工作正常。

#2


0  

This is not a proper fix, but it worked for me, so you can give it a try. Go to super user mode and then do npm install with sudo.

这不是一个正确的解决方案,但它对我有用,所以你可以尝试一下。转到超级用户模式,然后使用sudo执行npm install。

sudo su
sudo npm install

#3


0  

I had this exact same error with installing chimp (not from a git repo) after I'd upgraded from NodeJS 6.10 to 8.10 (and more importantly, to NPM 5.6.0). The problem is that npm 5 handles permissions / directories very differently than npm 4.

在我从NodeJS 6.10升级到8.10(更重要的是,到NPM 5.6.0)后,我安装了chimp(不是来自git repo)时出现了同样的错误。问题是npm 5处理权限/目录的方式与npm 4完全不同。

The solution is to NEVER use sudo when running npm 5. You'll find cases of when you have to use it with npm 4, but you shouldn't need to use sudo with npm 5. If you're installing globally, this link might help you. It didn't help me.

解决办法是在运行npm 5时不要使用sudo。你会发现你必须在npm 4中使用它的情况,但你不需要在npm 5使用sudo。如果你在全球安装,这个链接可能会帮助你。它没有帮助我。

Since I was in a docker container, I could just modify my docker file to not use sudo and then everything was fine. If you're not, I suggest you run the following as your user (not root):

由于我在一个docker容器中,我可以修改我的docker文件以不使用sudo然后一切都很好。如果您不是,我建议您以用户身份运行以下内容(不是root用户):

cd ~
sudo rm -rf .npm
cd 
npm cache clean
rm -rf node_modules
npm install

推荐阅读
  • React 小白初入门
    推荐学习:React官方文档:https:react.docschina.orgReact菜鸟教程:https:www.runoob.c ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • 在Kubernetes上部署JupyterHub的步骤和实验依赖
    本文介绍了在Kubernetes上部署JupyterHub的步骤和实验所需的依赖,包括安装Docker和K8s,使用kubeadm进行安装,以及更新下载的镜像等。 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • 本文介绍了在Ubuntu下制作deb安装包及离线安装包的方法,通过备份/var/cache/apt/archives文件夹中的安装包,并建立包列表及依赖信息文件,添加本地源,更新源列表,可以在没有网络的情况下更新系统。同时提供了命令示例和资源下载链接。 ... [详细]
  • RN即ReactNative基于React框架针对移动端的跨平台框架,在学习RN前建议最好熟悉下html,css,js,当然如果比较急,那就直接上手吧,毕竟用学习前面基础的时间,R ... [详细]
  • ReactJSUIAnt设计空组件原文:https://w ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • Ubuntu安装常用软件详细步骤
    目录1.GoogleChrome浏览器2.搜狗拼音输入法3.Pycharm4.Clion5.其他软件1.GoogleChrome浏览器通过直接下载安装GoogleChro ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • 本文介绍了在Android Studio中使用命令行build gradle的方法,并解决了一些常见问题,包括手动配置gradle环境变量和解决External Native Build Issues的方法。同时提供了相关参考文章链接。 ... [详细]
  • Question该提问来源于开源项目:react-native-device-info/react-native-device-info ... [详细]
  • Vue基础一、什么是Vue1.1概念Vue(读音vjuː,类似于view)是一套用于构建用户界面的渐进式JavaScript框架,与其它大型框架不 ... [详细]
author-avatar
lodng
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有