ios - 如何在 macbook pro big sur 上安装 expo CLI?
问题描述
我在新 Mac 上安装 expo 时遇到问题。当我运行这个命令时:
npm install --global expo-cli
我有错误:
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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
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! /Users/theowatine/.npm/_logs/2020-11-21T09_26_14_033Z-debug.log
有谁知道可能是什么解决方案?谢谢您的帮助!
解决方案
这是使用全局安装的npm
. 该npm
文档包含一个关于它的页面。
他们建议使用版本管理器(如)重新安装node
/ 。如果您在本地开发某些东西,这通常是一个非常好的选择。如果你这样做,这个问题就会消失。如果你愿意,你可以停止阅读这个答案。npm
nvm
它们还提供了一种配置方式npm
,将全局安装的项目放在您选择的目录中。如果版本管理器出于某种原因无法为您工作,这也是一个不错的选择。
他们提到的另一个选择是使用npx
而不是全局安装该工具。我经常使用这个并且非常喜欢它,但这确实意味着您经常必须记住在看到的命令前加上npx
.
他们没有列出两个比较常见的选项。一种是使用sudo
. 这意味着任何生命周期脚本都将在您的机器上以 root 身份运行。这通常是一个坏主意(这就是他们在文档中没有提到它的原因),但很常见。
另一种选择是chmod
您的/usr/local/lib/node_modules
目录,以便您可以写入它。在我看来,这也不是一个好主意(这可能是文档中也没有提到它的原因),但人们会这样做。
在expo-cli
大多数本地开发的情况下,使用包管理器安装nvm
可能是要走的路。
推荐阅读
- r - 从闪亮的apps.io下载将csv文件导入谷歌表格
- mysql-5.6 - Mysql - 在视图中每 n 行增加一次日期时间
- xml - 如何使用 xpath 获取特定的 xsd 元素?
- sql-server - 如何将具有检查约束的新列添加到具有单个 ALTER 表语句的表中?
- xml - 有没有办法在 Azure 存储帐户(BLOB)的 Visual Studio 中通过“XML 任务”执行 XSLT
- javascript - 如何使用 JavaScript 在 Excel 加载项中进行跨域 API 调用?
- javascript - 如何根据百分比添加 svg 圆?
- python - AttributeError:模块“win32ctypes.pywin32.win32api”没有属性“错误”
- python - 有没有办法使用python在json中列出未知数量的元素?
- node.js - 我如何在节点/adonis 中返回特定状态 + 消息?