Search code examples
javascriptreactjsgulp

Cannot find module 'reactcomponent'


Please I am stuck

I am web developer used to generate html from the backend

Just switching to react and seems like a pain in the ...

structure

bower.json

{
  "name": "ps-full-stack",
  "description": "",
  "main": "index.js",
  "authors": [
    "radu.hulubas <razorflashmedia>"
  ],
  "license": "ISC",
  "homepage": "",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "react": "^16.1.0"
  }
}

package.json

{
  "name": "ps-full-stack",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babelify": "^8.0.0",
    "browser-sync": "^2.24.7",
    "browserify": "^16.2.2",
    "ejs": "^2.6.1",
    "express": "^4.16.3",
    "gulp": "^3.9.1",
    "gulp-live-server": "0.0.31",
    "path": "^0.12.7",
    "react": "^16.4.2",
    "reactify": "^1.1.1",
    "vinyl-source-stream": "^2.0.0"
  },
  "devDependencies": {
    "babel-preset-es2015": "^6.24.1",
    "cross-env": "^5.2.0"
  }
}

main.jsx

var itemlist = require('./components/itemlist');
React.render(<itemlist/>, app);

The error I am getting is -

Error: Cannot find module './components/itemlist' -

which makes no sense, since the path is correct


Solution

  • The problem was with badly written require statement.

    This:

    var itemlist = require('./components/itemlist');
    

    Should be change by this:

    var itemlist = require('./components/itemlist.jsx');