android - 无法使用 npm install -g 安装 turtle-cli
问题描述
我使用 expo 开发了一个应用程序,并且由于 react-native-sound 模块我需要构建一个 apk 来测试我的程序,但我必须在本地构建,所以我尝试安装 turtle-cli 但我有很多错误而且我没有' t 知道如何解决它。
expo diagnostics
返回:
Expo CLI 3.17.18 environment info:
System:
OS: Linux 5.5 Fedora 30 (Workstation Edition) 30 (Workstation Edition)
Shell: 5.7.1 - /usr/bin/zsh
Binaries:
Node: 10.19.0 - /usr/bin/node
npm: 6.14.4 - /usr/local/bin/npm
npmPackages:
expo: ~37.0.3 => 37.0.6
react: ~16.9.0 => 16.9.0
react-native: ^0.62.2 => 0.62.2
npmGlobalPackages:
expo-cli: 3.17.18
首先我尝试不使用 sudo:
...
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/Osmonoz/.npm/_logs/2020-04-09T10_00_56_580Z-debug.log
还有sudo npm install -g turtle-cli
错误:
...
> dtrace-provider@0.8.8 install /usr/local/lib/node_modules/turtle-cli/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/10.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/turtle-cli/node_modules/dtrace-provider/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/turtle-cli/node_modules/dtrace-provider/.node-gyp'
gyp ERR! System Linux 5.5.10-100.fc30.x86_64
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/turtle-cli/node_modules/dtrace-provider
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
> iltorb@2.4.5 install /usr/local/lib/node_modules/turtle-cli/node_modules/iltorb
> node ./scripts/install.js || node-gyp rebuild
WARN install EACCES: permission denied, access '/root/.npm'
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/10.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/turtle-cli/node_modules/iltorb/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/turtle-cli/node_modules/iltorb/.node-gyp'
gyp ERR! System Linux 5.5.10-100.fc30.x86_64
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/turtle-cli/node_modules/iltorb
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
> sharp@0.24.1 install /usr/local/lib/node_modules/turtle-cli/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
ERR! sharp EACCES: permission denied, mkdir '/root/.npm'
info sharp Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/10.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/turtle-cli/node_modules/sharp/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/turtle-cli/node_modules/sharp/.node-gyp'
gyp ERR! System Linux 5.5.10-100.fc30.x86_64
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/turtle-cli/node_modules/sharp
gyp ERR! node -v v10.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.24.1 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.24.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-04-09T09_48_07_424Z-debug.log
我希望有人知道我做错了什么,
谢谢
解决方案
我找到了答案,这很简单,我只需要--unsafe-perm
在命令中添加标志:
sudo npm install -g turtle-cli --unsafe-perm
它写在错误下面..
info sharp Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
推荐阅读
- java - 如何在 Spring 安全配置中检查 OAuth2 客户端 ID?
- css - Angular:页面上的垫子菜单项太多
- swift - 当我键入 AF.request 时,什么都没有显示,但 Alamofire.request 正在工作,但 .GET 功能仍然没有显示出来。我如何解码数据
- c# - 使用冒号(:) 连接嵌套对象字段名称
- python - 在不使用熊猫的情况下在另一个数组中查找一个数组的元素索引的有效方法
- bloom-filter - 为什么布隆过滤器没有像 count-min 草图那样实现?
- python - 等待分组芹菜任务在python中完成
- json - Shell Script jq 在变量中读取带有句点 (.) 的 json 键
- php - OCS Inventory 不查询 BSSID 和 SSID
- serilog - Serilog - 仅保留 7 个最新文件