facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.23k stars 626 forks source link

Error "does not exist in the Haste module map" for already installed packages. #379

Open ziyoshams opened 5 years ago

ziyoshams commented 5 years ago

Do you want to request a feature or report a bug? Maybe a bug.

What is the current behavior?

error: bundling failed: Error: Unable to resolve module `@react-native-community/netinfo`  
 from `.../src/containers/Main.js`: Module `@react-native-community/netinfo` does not exist  
 in the Haste module map or in these directories: .../node_modules/@react-native-community

Please Note, this this error is not specific to netinfo. I also had the same issue with react-native-extra-dimensions-android. What is the expected behavior? Not throw error for already installed packages.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system. Mac OS High Sierra node: v10.14.1 npm: 6.5.0 react-native: 0.59.1

metro.config.js

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
  resolver: {
    blacklistRE: blacklist([/nodejs-assets\/.*/, /android\/.*/, /ios\/.*/, /unity\/.*/])
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false
      }
    })
  }
};

Following steps did not solve the issue:

Anyone else having the same issue?

ziyoshams commented 5 years ago

I guess this is the reason

npm WARN @react-native-community/netinfo@1.4.0 requires a peer of react-native@>=0.57 <0.59 but none is installed. You must install peer dependencies yourself.
erikrahm commented 5 years ago

Having this same issue when trying to use apollo-client, very frustrating

EvertonCosmo commented 5 years ago

same here with serialport https://github.com/node-serialport/node-serialport

: Module stream does not exist in the Haste module map

idhindsight commented 5 years ago

I guess this is the reason

npm WARN @react-native-community/netinfo@1.4.0 requires a peer of react-native@>=0.57 <0.59 but none is installed. You must install peer dependencies yourself.

Did you actually determine this was the root cause? Were you able to resolve it?

ziyoshams commented 5 years ago

I guess this is the reason

npm WARN @react-native-community/netinfo@1.4.0 requires a peer of react-native@>=0.57 <0.59 but none is installed. You must install peer dependencies yourself.

Did you actually determine this was the root cause? Were you able to resolve it?

Unfortunately no. I upgraded the packages to their latest and it works again. Not sure what the issue is.

jupmorenor commented 5 years ago

Also experimenting the issue, i'm using nodejs-websocket and it has dependences from @types/node like net module, and they are already installed but it fails to find it.

rochapablo commented 5 years ago

https://github.com/facebook/metro/issues/391#issuecomment-526140445

ssalexa commented 4 years ago

Same issue here. Looking for solution