I install bootstrap with
我安装bootstrap
npm install bootstrap --save
in my express project, then bootstrap is installed in node_modules
, but how can I access the js
and css
in my jade file?
在我的快递项目中,然后bootstrap安装在node_modules中,但是如何在我的jade文件中访问js和css?
2 个解决方案
#1
Node_modules is meant to use for server modules. NPM is server package management system.
Node_modules用于服务器模块。 NPM是服务器包管理系统。
You should use client package management system like bower for your client side modules i.e. Bootstrap.
您应该使用客户端包管理系统,如bower,用于客户端模块,即Bootstrap。
Once you set up bower, you'll be able to reference bower_components in your html files.
设置bower后,您将能够在html文件中引用bower_components。
#2
It depends on how you configure your static server, e.g.:
这取决于您如何配置静态服务器,例如:
app.use(express.static('public'));
So if node_modules
is placed into public
folder, your jade
file will be:
因此,如果将node_modules放入公共文件夹,您的jade文件将是:
script(src='/node_modules/bootstrap/js/file.js')
But better approach is use bower_component
instead of node_modules
on the client-side
但更好的方法是在客户端使用bower_component而不是node_modules
#1
Node_modules is meant to use for server modules. NPM is server package management system.
Node_modules用于服务器模块。 NPM是服务器包管理系统。
You should use client package management system like bower for your client side modules i.e. Bootstrap.
您应该使用客户端包管理系统,如bower,用于客户端模块,即Bootstrap。
Once you set up bower, you'll be able to reference bower_components in your html files.
设置bower后,您将能够在html文件中引用bower_components。
#2
It depends on how you configure your static server, e.g.:
这取决于您如何配置静态服务器,例如:
app.use(express.static('public'));
So if node_modules
is placed into public
folder, your jade
file will be:
因此,如果将node_modules放入公共文件夹,您的jade文件将是:
script(src='/node_modules/bootstrap/js/file.js')
But better approach is use bower_component
instead of node_modules
on the client-side
但更好的方法是在客户端使用bower_component而不是node_modules