Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

permission denied while trying to create leading directories of git clone

Tags:

git

npm

Whenever I try to run npm install on my app, I get the following error:

Eliyas-MacBook-Pro:app-name root# npm install
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone -q https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git /var/root/.npm/_cacache/tmp/git-clone-31357d5e
npm ERR! fatal: could not create leading directories of '/var/root/.npm/_cacache/tmp/git-clone-31357d5e': Permission denied
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2018-02-27T20_18_34_759Z-debug.log

This is what I get when I check the permission of the .npm folder:

drwxrwxrwx   6 root  staff  192 Feb 27 22:11 .npm

My environment:

  • git version 2.14.3 (Apple Git-98)
  • node v9.4.0
  • npm v5.4.0
like image 341
Eliya Cohen Avatar asked Feb 27 '18 20:02

Eliya Cohen


2 Answers

In that case I recommend you download the master.zip file from the git repo, then install it.

$> wget https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk/archive/master.zip

$> unzip master.zip

$> mv master cordova-plugin-googlemaps-sdk

$> cd (your project dir)

$> cordova plugin add (path to)/cordova-plugin-googlemaps-sdk

$> cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="..."  --variable API_KEY_FOR_IOS="..." 

(update)

The problem might be the git command version is out-of-dated. In order to upgrade the git command, you may choose :

(option 1)
$> brew upgrade git

(option 2)
Install the latest git command from here
https://git-scm.com/
like image 55
wf9a5m75 Avatar answered Oct 20 '22 02:10

wf9a5m75


I got that error when running npm install on a mounted volume on a Jenkins server.

In my case the issue was caused by this bug: Failed to install npm package from git in docker since v6.11.0 Which is also mentioned here: Cannot install packages from GitHub when mounting directory (node:12-slim)

The bug is fixed in npm version v6.13.6

I used node 12.13.0 and upgrading to version >14 (which contains npm version v6.13.6) fixed my problem.

like image 2
brass monkey Avatar answered Oct 20 '22 03:10

brass monkey