我有一些名为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>
);
}
});
我正在尝试使用browserify并用它重新执行:
browserify -t reactify main.js
但是我收到了这个错误:
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)
鉴于我已经安装了react
和reactify
npm模块:
npm install -g react
npm install -g reactify
答案 0 :(得分:14)
我发布问题的那一刻,似乎我找到了答案,在本地安装了模块修复它。
npm install react
但后来又出现了另一个错误:
Error: EMFILE, open '/Users/jameslin/node_modules/react/package.json'
更新:
正在运行ulimit -n 10000
解决了问题