react-native - 安装 fs-extra 时失败 - react-native
问题描述
〜我正在为android创建一个新应用程序,当我命令react-native run-android时出现此错误:错误:捆绑失败:错误:无法解析模块fs
来自C:\Users\luis.arnoni.fritzen\Documents\ReactNative\Hello\node_modules\expo-cli\build\exp.js
:fs
Haste模块映射中不存在模块
阅读一些文档,这似乎是 fs 包的问题。我尝试安装 fs-extra 包,但出现错误
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9
(node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation
not permitted, rename
'C:\Users\luis.arnoni.fritzen\Documents\ReactNative
\Hello\node_modules\.staging\fsevents-aa6bf958\node_modules\rc' ->
'C:\Users\luis.arnoni.fritzen\Documents
\ReactNative\Hello\node_modules\.staging\rc-e2a21b3f'
npm ERR! path C:\Users\luis.arnoni.fritzen\Documents\ReactNative\
Hello\node_modules\fs-extra\lib\fs
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink
'C:\Users\luis.arnoni.fritzen\Documents\
ReactNative\Hello\node_modules\fs-extra\lib\fs'
npm ERR! { [Error: EPERM: operation not permitted, unlink
'C:\Users\luis.arnoni.fritzen\Documents\ReactNative\
Hello\node_modules\fs-extra\lib\fs']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink
'C:\Users\luis.arnoni.fritzen\Documents\ReactNative\
Hello\node_modules\fs-extra\lib\fs'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR!
'C:\\Users\\luis.arnoni.fritzen\\Documents\\ReactNative\\
Hello\\node_modules\\fs-extra\\lib\\fs' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, unlink
\'C:\\Users\\luis.arnoni.fritzen\\Documents\\
ReactNative\\Hello\\node_modules\\fs-extra\\lib\\fs\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'C:\\Users\\luis.arnoni.fritzen\\Documents\\
ReactNative\\Hello\\node_modules\\fs-extra\\lib\\fs',
npm ERR! parent: 'Hello' }
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 (though this is not
recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\luis.arnoni.fritzen\AppData\Roaming\npm-
cache\_logs\2019-09-16T16_08_43_971Z-debug.log
解决方案
react-native
没有完整的节点环境。并非所有节点模块都可以与 react-native 一起使用。您可以考虑使用https://github.com/itinance/react-native-fs
推荐阅读
- vb.net - 带有 RightToLeft 和数字前导文本的单选按钮将数字移动到结尾
- c++ - developertudio 12.6 在 solaris 上的内联问题
- scala - 如何允许调用者调用案例类字段的方法?
- google-cloud-platform - 是否有用于导出 spanner 数据库的 gcloud 命令?
- php - 当 Woocommerce 允许一个国家/地区时,将状态字段保留为下拉列表
- java - 如何在列表片段AndroidStudio中添加图像和文本
- regex - 获取url参数并保存变量或cookie
- python - 没有重复元素的Python随机函数
- android-room - @Update 在 Room 中的 OnConflictStrategy 的目的是什么?
- python - 遍历一个 json 列表并使用 Python 获取特定的键和值