简体   繁体   English

使用 load_paths 时未找到 Jekyll node_modules

[英]Jekyll node_modules not found while using load_paths

I am trying to configure jQuery in a Jekyll project.我正在尝试在 Jekyll 项目中配置 jQuery。 I am having issues referencing my script tags (if I include a cdn its fine).我在引用我的脚本标签时遇到问题(如果我包含一个 CDN 就好了)。

I was reading up on some issues where github-pages may not process your node_modules.我正在阅读一些 github-pages 可能无法处理您的 node_modules 的问题。 But, I am just working locally with no luck.但是,我只是在本地工作,没有运气。

Would js files be loaded differently not under a sass: > load_paths: ? js 文件是否会以不同的方式加载而不是在sass: > load_paths: Does it matter?有关系吗? (Sass files work fine but no js files are working) (Sass 文件工作正常,但没有 js 文件工作)

_config.yml _config.yml

sass:
  load_paths:
    - _sass
    - node_modules/

My footer:我的页脚:

<script src="{{'/node_modules/jquery/dist/jquery.min.js' | prepend: site.baseurl}}"></script>

Error:错误:

[2019-03-27 12:44:36] ERROR `/node_modules/jquery/dist/jquery.min.js' not found. [2019-03-27 12:44:36] 找不到错误`/node_modules/jquery/dist/jquery.min.js'。

Had the same issue.有同样的问题。 For me adding following to the _config.yml helped:对我来说,在 _config.yml 中添加以下内容有帮助:

include             : [".htaccess", "node_modules"]
exclude             : ["Gemfile", "Gemfile.lock", "vendor/bundle/", "vendor/cache/", "vendor/gems/", "vendor/ruby/"]

It seems like just removing "node_modules" from exclude does not help, you have to explicitely add it to the includes.似乎只是从排除中删除“node_modules”没有帮助,您必须明确地将其添加到包含中。

添加exclude: []my _config.yml文件修复了这个问题,如果这对任何人my _config.yml帮助。

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

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