Trying to install Material Web Components but never works. #5214
-
Hello to y'all. I try to install Material Web Components to be used in my website. But no matter how I install it, it always doesn't work. Tried installing using node.js doesn't work, manually downloading all the modules, doesn't work. Using CDN, doesn't work. Using frameworks like lit.dev works using their playground, but installing locally than use from that doesn't work. I don't know what works. Hopefully you all can help me here. I'm not pro, but I'm learning rn. OS (1st try): Windows 11 IoT Enterprise Idk how to print verbosely, but what i do know, no elements of MWC is displaying. It just shows normal HTML tag/ text. Edit: I just realized there is same discussion like mine discussions/4427. I'll try that first, then I'll let y'all know if it fixes. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Nope, it doesn't work. |
Beta Was this translation helpful? Give feedback.
-
when you try installing it via nodejs, what output do you get? |
Beta Was this translation helpful? Give feedback.
-
Does this work for you? https://github.com/datvm/mdc-start-template Just clone that one, run |
Beta Was this translation helpful? Give feedback.
Ok, Npm doesn't seem to be the issue. From the limited information available, it looks like you may be trying to use material web without a build tool.
Try
npm install vite
, create anindex.html
(if you don't have one), then runnpx vite
, which will start up a server.The thing with material web is you need some sort of build tool that transforms it's code into code understandable by a browser. Vite is one of those build tools, and it usually just works.
After that, you can just create a JavaScript file, import it in the html (e.g.
<script type="module" src="./main.js">
), and import the components you need in that js file: