如何解决无法在命令提示符下更新或执行“expo”命令
我第一次尝试在我的项目目录上安装 expo-cli 它起作用了。我可以使用 expo init
在命令提示符中制作我的第一个 React Native 应用程序,并使用 expo start
运行该应用程序。但是现在当我有一些新项目要使用“expo”命令(如 expo init
或 expo start
或其他东西)时,它不再起作用了。当我尝试键入并输入 expo 命令时,它始终是
'expo' is not recognized as an internal or external command,operable program or batch file.
现在,当我尝试使用 npm install -g expo-cli
更新 expo-cli 时,出现了错误警告。
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli
npm ERR! dest C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted,rename 'C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli' -> 'C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w'
npm ERR! [Error: EPERM: operation not permitted,rename 'C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli' -> 'C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w'] {
npm ERR! errno: -4048,npm ERR! code: 'EPERM',npm ERR! syscall: 'rename',npm ERR! path: 'C:\\Users\\ACER\\AppData\\Roaming\\npm\\node_modules\\expo-cli',npm ERR! dest: 'C:\\Users\\ACER\\AppData\\Roaming\\npm\\node_modules\\.expo-cli-foqoNR8w'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),npm ERR! or that you lack permissions to access it.
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! C:\Users\ACER\AppData\Local\npm-cache\_logs\2021-01-10T17_18_03_575Z-debug.log
这使我无法安装反应导航并使用“expo”命令创建新项目。我一直在搜索这个问题并试图解决它,但它在我尝试过的任何各种方法上都不起作用。我尝试重新安装 expo-cli 但它没有用,我也尝试使用 yarn
但仍然没有用。我已经重新添加了 npm 的路径,甚至尝试重新安装 nodejs 并使用任何各种代码来更新和安装“expo-cli”,但它没有按预期工作。
有什么建议可以解决这个问题吗?
解决方法
以管理员身份运行命令行,然后执行以下操作:
npm remove -g expo-cli
删除现有的 CLI
然后 npm i -g expo-cli
重新安装 Expo CLI。
然后您只需通过 expo login
登录(如果您已登录)并从您所在的位置起飞!
我删除了路径上的expo文件:
C:\Users\ACER\AppData\Roaming\npm\node_modules\expo-cli
C:\Users\ACER\AppData\Roaming\npm\node_modules\.expo-cli-foqoNR8w
我删除的文件: expo-cli & .expo-cli-foqoNR8w
然后尝试使用 npm install --global expo-cli
再次安装 expo-cli,然后它就可以工作了。现在我可以使用我的 expo start
或任何带有“expo”的代码。而且现在我可以在我的项目目录上安装反应导航。我正在使用以管理员身份运行的命令提示符运行安装。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。