“无法解析模块路径"在 React Native 中 [英] "Unable to resolve module path" in React Native

查看:61
本文介绍了“无法解析模块路径"在 React Native 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加新依赖项后,我在 React Native 应用程序的红屏中收到错误消息无法解析模块路径".我已尝试按照屏幕指示清除缓存.

After adding a new dependency, I get the error message "Unable to resolve module path" in a red screen in my React Native app. I've tried clearing the cache as the screen instructs.

(问题很简短,因为我是自己回答的)

推荐答案

错误信息:

无法解析模块路径

应该是:

无法解析模块路径"

path 是它无法加载的模块的名称!我正在阅读错误消息无法解析模块的路径".

path is the name of the module it can't load! I was reading the error message as "can't resolve a path to the module".

所以根本原因是,它在错误消息中列出的文件正在导入本机 Node 模块 path,这在 React Native 上不可用.

So the root cause is, the file it lists in the error message is importing the native Node module path, which isn't available on React Native.

解决办法是npm install -D path,这是一个副本实现.

The solution is to npm install -D path, which is a replica implementation.

这篇关于“无法解析模块路径"在 React Native 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆