简体   繁体   English

如何从 npm 包中获取 css 文件到链接的 href

[英]How to get css file to href of link from npm package

I've installed a package from npm.我已经从 npm 安装了一个包。

npm install lightgallery

I need to fill href of link with this package's css file directory.我需要用这个包的 css 文件目录填充链接的 href 。 Like this:像这样:

<link rel="stylesheet" href="/node_modules/lightgallery/css/lightgallery.css" />

But I can't reach the files in node_modules .但我无法访问node_modules的文件。 I'm using express.static , maybe this problem stems about static files...我正在使用express.static ,也许这个问题源于静态文件......

app.use('/assets', express.static('assets')) 

How can I serve that file and use it in link href?如何提供该文件并在链接 href 中使用它?

Okay I solve it!好的我解决了!

I served node_modules like this:我为 node_modules 提供了这样的服务:

app.use('/node_modules', express.static('node_modules'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM