Eliya Cohen
Eliya Cohen

Reputation: 11518

permission denied while trying to create leading directories of git clone

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:

Upvotes: 6

Views: 18824

Answers (3)

brass monkey
brass monkey

Reputation: 6781

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.

Upvotes: 2

PDZ
PDZ

Reputation: 3

Maybe need root rights.

sudo npm install

Upvotes: -3

wf9a5m75
wf9a5m75

Reputation: 6158

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/

Upvotes: 3

Related Questions