Unable to resolve module…does not exist in the haste module map

北城余情 提交于 2019-12-10 17:39:04

问题


I am a beginner on ReactNative, I am creating a Twitter clone to practice.

I had already developed a first application and I had no problem.

But since I started the new project, after adding custom modules in the project I have this error message.

In this case I want to import a style sheet into my custom Tweet component, I added a capture, it's better for you.

Screenshot - error message

So, I followed all the instructions of the capture, except Watchmen because I'm working on Windows 10, after doing the procedure, I recreated a new project with "react-create-app", restart XDE expo and the application but the problem comes back ...

I also tried the Github procedure dealing with the problem (see the catch for the issue) here => https://github.com/facebook/react-native/issues/4968


回答1:


Simply follow again below steps

yarn add react-native-tweet-view
react-native link react-native-tweet-view



回答2:


check the top of your file so that you have not imported

import { threadId } from 'worker_threads';

I removed that and it worked




回答3:


There is 3 issue in your import :

  1. You must not write the extension of the module you're importing
  2. Your file is named "Tweet.style" and you try to import "Tweet.styles"
  3. You have to import the relative path of your module

Correct import should be :

import styles from './Tweet.style'



回答4:


Some time this error happens because of malformed JS styles .. like

backgroundColor= '#fff'

instead of backgroundColor: '#fff' this ..



来源:https://stackoverflow.com/questions/50844133/unable-to-resolve-module-does-not-exist-in-the-haste-module-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!