ds300 / react-native-typescript-transformer

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

Broken in react-native@0.46 #20

Closed iRoachie closed 7 years ago

iRoachie commented 7 years ago

I think they're some new changes regarding the packager in the newest version of react-native.

Error looks like this: Cannot find module 'react-native/packager/transformer'

ds300 commented 7 years ago

That's odd. With the latest version of react-native-typescript-transformer, the error should hopefully be Cannot find module 'metro-bundler/src/transformer' if #19 is anything to go by.

Anyway proper 0.46 support is top priority for me today after work, in a few hours.

iRoachie commented 7 years ago

@ds300 There seems to be another problem as well with react-native's transformer in general. https://github.com/facebook/react-native/issues/14866

I'll close this now since there's a PR for this already.

rochapablo commented 6 years ago

I still having this error

https://github.com/facebook/react-native/issues/14866#issuecomment-337889887

Using:

"react-native-typescript-transformer": "^1.1.4"
pehlert commented 6 years ago

I was having this issue as well and was able to fix this by manually installing metro-bundler as a dev dependency (latest, v0.20.0 as of now) as this seems to be where react-native-typescript-transformer tries to require from.

My env: React: 16.0.0-alpha.12 React Native: 0.48.0 react-native-typescript-transformer: 1.1.4

Command that fixed it: npm install --save-dev metro-bundler

ds300 commented 6 years ago

Yes if you're seeing this error Cannot find module 'react-native/packager/transformer' it means that the following code is failing:

https://github.com/ds300/react-native-typescript-transformer/blob/987f87a9cfea0e89aad873858d9c6b823572b26c/index.js#L12:L28

So metro-bundler is probably either installed in a nested node_modules somewhere, or is using a new directory structure so the transformer can't be loaded from 'metro-bundler/src/transformer' or 'metro-bundler/build/transformer'

Doing what @pehlert suggested should fix the problem in the first case. In the last case you should submit a new issue.