ds300 / react-native-typescript-transformer

Seamlessly use TypeScript with React Native
MIT License
657 stars 55 forks source link

Module `@components/Hello` does not exi st in the Haste module map #85

Closed fantasy525 closed 5 years ago

fantasy525 commented 5 years ago

my tsconfig.json

...
 "paths": {
      "@components/*":["src/components/*"]
    }, 
...

and my app.tsx

import Hello from '@components/Hello'

and tsc check is no errors but bundling failed

error: bundling failed: Error: Unable to resolve module `@components/Hello` f
rom `F:\RN\TS\UserTrain\src\App.tsx`: Module `@components/Hello` does not exi
st in the Haste module map

why?

FabianMeul commented 5 years ago

I'm facing the same issue.

tsconfig.json

"baseUrl": "./src", 
"paths": {
    "@/*": ["/*"],
    "@components": ["components"],
    "@components/*": ["components/*"],

SomeComponent.tsx

import { StyledText, StyledButton } from "@components";
error: bundling failed: Error: Unable to resolve module `@components` from `/Users/xxx/project-name/src/components/Partner/Partner.tsx`: Module `@components` does not exist in the Haste module map
tkulpa commented 5 years ago

Im also having this problem, did you find solution for this? @FabianMeul, @fantasy525?

Lxxyx commented 5 years ago

Same issue, any updates?

stepankoci commented 5 years ago

Add the package.json file to the components (target) directory with following content:

{
  "name": "@components",
  "private": true
}

(I'm not sure about @ in the package name)

Lxxyx commented 5 years ago

@fantasy525 @FabianMeul @tkulpa By follow @stepankoci reply, Issue resolved.

fantasy525 commented 5 years ago

@fantasy525 @FabianMeul @tkulpa By follow @stepankoci reply, Issue resolved. nice ,it works for me