每当我尝试在我的应用上运行npm install
时,都会收到以下错误:
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
这是我在检查.npm
文件夹的权限时得到的结果:
drwxrwxrwx 6 root staff 192 Feb 27 22:11 .npm
我的环境:
答案 0 :(得分:2)
在这种情况下,我建议你从git repo下载master.zip文件,然后安装它。
$> 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="..."
(更新)
问题可能是git命令版本已过时。 要升级git命令,您可以选择:
(option 1)
$> brew upgrade git
(option 2)
Install the latest git command from here
https://git-scm.com/
答案 1 :(得分:1)
也许需要root权限。
sudo npm install
答案 2 :(得分:0)
我在 Jenkins 服务器上的已安装卷上运行 npm install
时遇到该错误。
就我而言,问题是由这个错误引起的: Failed to install npm package from git in docker since v6.11.0 这里也提到了: Cannot install packages from GitHub when mounting directory (node:12-slim)
该错误已在npm v6.13.6 版
中修复我使用节点 12.13.0 并升级到版本 >14(包含 npm 版本 v6.13.6)解决了我的问题。