Cannot include node_modules

I’m trying to make Jekyll serve node_modules on GitHub Pages. The following is my _config.yml:

  - node_modules

What am I doing wrong?

that sounds like a terrible idea, why? usually there is a million files in there.

Do you need them for a JS app? shouldn’t your build process create what you need in a new js file?

With that in the config is there no node_modules folder in the site folder? I think jekyll tries pretty hard to ignore that folder, maybe just having it in the include is not enough?

according to the docs you should be able to include them like you did:

maybe you have a syntax error in the way you did it? looks right to me though but maybe there is more in your config file that is causing an issue.

of course you are trying to do this on GH pages, how? are you committing the site folder? I think you would have to. So you need to build it locally and get the node_modules folder into your site folder locally, then push the site folder and then it may work.

Still think it is a bad idea, likely another way to do what you want I would think.

@rdyar I understand your objection, but I won’t ever have hundreds of files in this node_modules directory.

Please see the files. Am I missing anything? is inaccessible.

node_modules is excluded by default. So with versions older than Jekyll 4.0, you need to override the exclude array:

# _config.yml with Jekyll 3.8.x and older

# override the default exclude array
  - Gemfile
  - Gemfile.lock
  - vendor/

With Jekyll 4.0, you may simply include stuff excluded:

# _config file with Jekyll 4.0.0 (and newer)

  - .htaccess
  - node_modules

@ashmaroli Thanks! I’ve changed the config as suggested, but the referenced file is still inaccessible. Am I still missing something?

However, I’m able to access the file as expected:

Now I can access it, too. It has taken a while for GitHub Pages to catch up. Thanks for everything!

1 Like