1

I have in stalled an npm package. Now I want to include the css and js files in my html page by typing something like this:

      <link href="/root/node_modules/quill/dist/quill.snow.css" rel="stylesheet">

But the above path does not work. My html page is located at /var/www/html What is the right way to do this. This is probably a duplicate but I am not able to find the answer.

1
  • can you edit your post to provide the file structure (preferably as text) Commented Oct 12, 2018 at 16:14

1 Answer 1

1

You need to make sure that your CSS and JS files are in the same directory (probably src/app) as your HTML files.

e.g.

src
 |
 | app
    |
    | css
    | js
   index.html

so the path to index.html in the web version is /index.html, and the path (relative to index.html) to the CSS folder is ./css.

Here's a great explanation of relative paths in node applications.

When using 3rd-party libraries such as CSS in node modules, you can use this in your stylesheet:

@import "~quill/dist/quill.snow";

You will also need to require the module in your config file - see this discussion in GitHub for more info.

Sign up to request clarification or add additional context in comments.

9 Comments

So I just copy the full package directory to my the website folder?
ah, if they are library CSS files that would be different
Sorry I don’t get that.
I mean if they are part of the npm package, you should use them from there. Just trying figure out how you should reference them, I'll be right back :) Are you using SCSS?
Tanks alot for helping!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.