Skip to content

Module not found: Error: Cannot resolve module 'react-native' when changing css #518

Closed
@luizkowalski

Description

@luizkowalski

I have two file: Navbar.js and Navbar.css
the Navbar.js is as follows

import React from 'react';
import './Navbar.css'
import githubLogo from '../github-octocat.svg';

const Navbar = React.createClass({

  render(){
    return(
      <nav className="nav">
        <div className="nav-left">
          <a className="nav-item is-brand" href="#">
            <img src={githubLogo} alt="Bulma logo" />
            Chathub
            </a>
          </div>

          <div className="nav-center">

          </div>

          <span className="nav-toggle">
            <span></span>
            <span></span>
            <span></span>
          </span>

          <div className="nav-right nav-menu">
            {
              this.props.logged ? (
            <span className="nav-item">
              <a className="button is-primary" onClick={this.props.logout}>
                <span className="icon">
                  <i className="fa fa-cog"></i>
                </span>
                <span>Logout</span>
              </a>
            </span>
          ) : '' }
          </div>
        </nav>
      )
    }
  });

  export default Navbar;

and the css is pretty simple

.nav-item img {
    max-height: 35px;
}

but, everytime I change the css and save, I get the following error in console

Error in ./src/components/Navbar.js
Module not found: Error: Cannot resolve module 'react-native' in /Users/luizeduardo/js_dev/chub/src/components
resolve module react-native in /Users/luizeduardo/js_dev/chub/src/components
  looking for modules in /Users/luizeduardo/js_dev/chub/node_modules
    /Users/luizeduardo/js_dev/chub/node_modules/react-native doesn't exist (module as directory)
    resolve 'file' react-native in /Users/luizeduardo/js_dev/chub/node_modules
      resolve file
        /Users/luizeduardo/js_dev/chub/node_modules/react-native doesn't exist
        /Users/luizeduardo/js_dev/chub/node_modules/react-native.js doesn't exist
        /Users/luizeduardo/js_dev/chub/node_modules/react-native.json doesn't exist

and my Navbar.js becomes this mess

import React, {StyleSheet, Dimensions, PixelRatio} from "react-native";
const {width, height, scale} = Dimensions.get("window"),
    vw = width / 100,
    vh = height / 100,
    vmin = Math.min(vw, vh),
    vmax = Math.max(vw, vh);

export default StyleSheet.create({
    "nav-item img": {
        "maxHeight": 35
    }
});

I'm not sure what is going on here. It is really strange that it has something to do with react-native

anyway, here is my package.json

{
  "name": "react-test",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "react-scripts": "0.2.1"
  },
  "dependencies": {
    "axios": "^0.13.1",
    "jquery": "^3.1.0",
    "material-ui": "^0.15.4",
    "react": "^15.2.1",
    "react-dom": "^15.2.1",
    "react-router": "^2.7.0",
    "react-tap-event-plugin": "^1.0.0",
    "react-timeago": "^3.1.2",
    "reactfire": "^1.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "./node_modules/react-scripts/config/eslint.js"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions