1

I'm trying to build the material-ui (material-ui.com) javascript so that I can include it in my project and use the react components. I've been using browserify to bundle all the javascript into a single file, which I then include in my HTML file. So, in the material-ui/lib directory (which is where the JSX-transformed JS seems to live -- I'm very new to NPM bundles + browserify etc), I run

browserify index.js -o material-ui.js -r material-ui

I then include that material-ui.js file in my HTML.

But then when I try writing require('material-ui') in my javascript in the HTML page I get "Cannot find module 'material-ui'".

I don't really understand what browserify is meant to be doing, what the require function is doing, and how I'm meant to reference any of the material-ui react classes. Thanks!

4

1 回答 1

1

所以我只是设法解决了这个问题。Browserify 正在创建一个 require() 函数,但没有创建 material-ui 模块,因为我从错误的目录中调用它。从 npm 的模块根目录调用它而不指定起始 .js 点以某种方式使其实际工作,允许我使用 require('material-ui') 没有任何错误。

于 2015-02-21T12:06:04.013 回答