Unable to resolve module....Expo fails to compile every time

Hi,

error

I am running Expo v20.20.1 on MacOS Sierra 10.12.6.

I am very frustrated with Expo as I have been getting the same error for weeks. I’ve tried so many different combinations of things to fix it, but nothing seems to work. Here’s a list of methods I have tried:

  1. I downgraded npm to 4.6.1 (expo’s suggestion), deleting node_modules and package.lock, and reinstalling.
  2. I’ve tried using yarn to install packages.
  3. I’ve tried deleting yarn.lock…package.lock… and node_modules and reinstalling.
  4. I’ve tried upgrading/updating brew and reinstalling yarn, and deleting the /usr/local/bin/yarn files.
  5. I’ve tried all the suggestions in the screenshot (clear watchman, delete node_modules, and reset packager cache).

Nothing seems to work, and I have no idea what to do.

For what it’s worth, I also always have this “issue” in Expo:

Warning: ‘react-native’ peer depencency missing. Run npm ls in /Users/mattfewer/dev/react-native/ganja to see full warning.
If there is an issue running your project, please run npm install in /Users/mattfewer/dev/react-native/ganja and restart.

Hey @mattyfew, I’d love to see your package.json and your App.json? can you show those to me? I’m so sorry you’re having this problem.

Hey @jimmylee, here you go:

package.json

{
  "name": "myApp",
  "version": "0.0.0",
  "description": "Hello Expo!",
  "author": "mattyfew",
  "private": true,
  "main": "main.js",
  "dependencies": {
    "expo": "17.0.0",
    "firebase": "^4.0.0",
    "lodash": "^4.17.4",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-17.0.0.tar.gz",
    "react-native-elements": "^0.12.2",
    "react-native-router-flux": "^3.39.1",
    "react-native-svg": "^5.1.8",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^5.0.5",
    "redux": "^3.6.0",
    "redux-thunk": "^2.2.0"
  }
}

App.js

import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import firebase from 'firebase';

import reducers from './reducers';
import ReduxThunk from 'redux-thunk';
import Router from './Router';

class App extends Component {
    componentWillMount(){
        const config = {
            apiKey : "xxx",
            authDomain : "xxx",
            databaseURL : "xxx",
            projectId : "xxx",
            storageBucket : "xxx",
            messagingSenderId : "xxx"
        };

        firebase.initializeApp(config);
    }



    render() {
        const store = createStore(reducers, {}, applyMiddleware(ReduxThunk));

        return (
            <Provider store={store}>
                <Router />
            </Provider>
        )
    }
}

export default App;

I replaced my values for config with xxxxxs for privacy reasons.

Is there a reason you’re using react-native-svg instead of Expo.Svg? https://docs.expo.io/versions/v17.0.0/sdk/svg.html

@mattyfew, I think @davepack’s instinct is right, because that library cannot be used while attached with Expo react-native-svg, since there is no SVG code in your app right now you might as well just take that library out.

@davepack @jimmylee No reason, I think I was just testing it out and forgot to remove it. I didn’t know you need to use the Expo.svg module. I will keep that in mind in the future.

However, I removed react-native-svg from my package.json, deleted node_modules, reinstalled with npm v4.6.1, and I still getting the same big red error that I originally posted :sob:.

@davepack @jimmylee Is there any possible solution to this? I’m at a complete standstill. Only option I can think of is to completely rewrite my application without Expo, which I really don’t want to do.

Have you tried clearing all the caches? React Native has several caches that could be possible failure points: How to clear the Expo and React Native packager caches (Metro, Watchman, Haste)

1 Like

Can you also paste the contents of app.json?

@mattyfew Hi Matty, did you get the solution to this? I’m currently experiencing the same problem :cold_sweat:

2 Likes

Hey @isaackdamian are you running the same SDK version as him? or the latest? Can you tell us a few more details about your project so we can help you resolve?

I’m running into the same issue with trying to add a font file (.tff) to /assets/fonts immediately after creating the sample app, which is quite annoying considering that adding fonts should be the easy part of building an application. The error message literally says that the font file does not exist despite it, well, existing… I have tried to clear expo’s cache to no avail. Please, any other suggestions? I just downloaded and installed all dependencies today so I should be using the latest versions of everything.

nobody with a usefull response huh?

1 Like

for me worker npm i

Make sure your package.json has all the packages you need and then do npm i

For me, an incorrect import was automatically added by VSCode- an import that made Expo very angry. I stashed my latest changes (which fixed the bug) and went through file by file until I found something really odd:

import { tmp } from "npm";

I think it was added in the middle of typing a tmpSomething variable. So I would recommend checking your imports for weird stuff too.