Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

browserify cannot find module 'react'

I have this bit of react code called main.js:

var React = require('react');

var Comment = React.createClass({
render: function(){
  return (
    <div className="comment">
      <h2 className="commentAuthor">
        {this.props.author}
      </h2>
      <span dangerouslySetInnerHTML={{__html:marked(this.props.children.toString(), {sanitize:true})}} />
    </div>
  );
}
});

And I am trying to use browserify and reactify with it:

browserify -t reactify main.js

But I am getting this error:

Error: Cannot find module 'react' from '/Users/jameslin/projects/reactjs/react-0.13.2'
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:46:17
    at process (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:173:43)
    at ondir (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:188:17)
    at load (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at Object.oncomplete (fs.js:107:15)

Given that I have installed react and reactify npm modules by:

  • npm install -g react
  • npm install -g reactify
like image 227
James Lin Avatar asked May 05 '15 20:05

James Lin


1 Answers

The moment I posted my question, and seems I found the answer, installed the module locally fixed it.

npm install react

But then I get another error:

Error: EMFILE, open '/Users/jameslin/node_modules/react/package.json'

UPDATE:

running ulimit -n 10000 fixed the issue

like image 66
James Lin Avatar answered Nov 15 '22 04:11

James Lin