【问题标题】:how to access node_module directory which was out side the static content serving folder如何访问静态内容服务文件夹之外的节点模块目录
【发布时间】:2016-03-06 15:40:48
【问题描述】:

需要从 index.html 文件中访问 node_module 目录文件,该文件位于子目录中,并且 node_module 目录与父目录位于同一位置。这里我使用 angularjs,服务器文件的静态文件夹是公共目录。

app.use(express.static(__dirname + '/public'));

截图中提供了目录结构enter image description here

【问题讨论】:

    标签: angularjs node.js express node-modules


    【解决方案1】:

    也试试这个 node_modules 文件夹

    app.use(express.static(__dirname + '/node_modules'));
    

    然后在 index.html 中你可以直接访问 node_modules 文件夹的子目录,例如。

    <script src="async/component.json"></script>
    

    【讨论】:

    • app.use(express.static(__dirname + '/node_modules'));不能使用这个,只是因为我们需要访问公用文件夹中的静态页面。它不在 node_module 文件夹中。
    • @JaisonAbraham 您不要替换“/public”行,而是创建一个看起来相似但用于 /node_modules 目录的新行。
    • @JaisonAbraham 我的意思是为 node_modules 文件夹添加另一行,如公用文件夹的行...。不替换公用文件夹行...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 2021-09-27
    • 2016-03-20
    • 2012-11-01
    相关资源
    最近更新 更多