React Native "Cannot find module 'react-native'" Problem

I installed react-native and the global cli.

But when I run npm start, I'm having this error:

Cannot find module 'react-native'

Here is my App.js file. Thank you...

import React from "react";
import { SafeAreaView, View, Text } from "react-native";

function App() {
  return (
    <SafeAreaView
      style={{
        flex: 1,
        alignItems: "center",
        justifyContent: "center",
      }}
    >
      <View
        style={{
          flex: 1,
          alignItems: "center",
          justifyContent: "center",
        }}
      >
        <View style={{ flex: 3 }}>
          <Text>Kayıt Listesi</Text>
        </View>
      </View>
    </SafeAreaView>
  );
}
export default App;

Upvotes: 2

Views: 11464

Answers (1)

David Scholz
David Scholz

Reputation: 9733

Execute the following steps:

  1. Remove your node_modules directory.
  2. Run npm install.
  3. Run npm start.

The command npm install install everything your project needs into the node_modules directory.

If this does not help, try to add react-native individually by executing the command npm install react-native --save.

It is usually a good idea to initialize a new project using npm init, which creates a package.json file in which npm stores names and versions of all installed packages.

Edit: After we have investigated the whole stack trace it is apparent that we need to install react-native-web via the command npm install react-native-web.

Upvotes: 5

Related Questions