Skip to content

Trying to install Material Web Components but never works. #5214

Answered by Aworldc
HaiziIzzudin asked this question in Q&A
Discussion options

You must be logged in to vote

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 an index.html (if you don't have one), then run npx 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:

import '@material/web/button/elevated-button.js';
import '@materia…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@HaiziIzzudin
Comment options

@Aworldc
Comment options

Answer selected by HaiziIzzudin
@HaiziIzzudin
Comment options

@asyncLiz
Comment options

Comment options

You must be logged in to vote
1 reply
@HaiziIzzudin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants