question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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"
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
quadsurfcommented, Dec 8, 2016

argh, i hate when the obvious eludes me! thanks @fson … it’s solved now!

1reaction
fsoncommented, Dec 8, 2016

@quadsurf You might have to restart Atom after uninstalling the plugin for the changes to take effect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't resolve module (not found) in React.js - Stack Overflow
It seems you need import Header from './components/header/header' w/o src. File path is relative to importing file path. Then you need to export ......
Read more >
Module not found | Can not resolve module in react - YouTube
React Course For Beginners - Learn React in 8 Hours · JS - JavaScript · Target container is not a DOM element error...
Read more >
How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change 'react-scripts' to 4.0.2 in your package.json and run `npm install` again :D Follow me on Twitter: ...
Read more >
Module not found: Can't resolve 'X' error in React | bobbyhadz
To solve the "Module not found: Can't resolve" error in React, make sure to install the package from the error message if it's...
Read more >
Troubleshooting | React Navigation
If the module points to an npm package (i.e. the name of the module doesn't with ./ ), then it's probably due to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found