Eleventy: Adding .gitignore file results in problem writing templates

Created on 16 Mar 2020  路  4Comments  路  Source: 11ty/eleventy

Describe the bug
I added a .gitignore file to my project. With an item listed in that file, building my site fails due to a template error. No templates are written.

To Reproduce
Steps to reproduce the behavior:

  1. Add a .gitignore file to your project root.
  2. Add an item in the file.
  3. Build your site via npx @11ty/eleventy.
  4. See error:
Problem writing Eleventy templates: (more in DEBUG output)
> Invalid data format returned from ./node_modules/@11ty/eleventy/test/stubs/exports-flatdata.11ty.js: typeof string

`JavaScriptTemplateInvalidDataFormatError` was thrown:
    JavaScriptTemplateInvalidDataFormatError: Invalid data format returned from ./node_modules/@11ty/eleventy/test/stubs/exports-flatdata.11ty.js: typeof string
        at JavaScript.getExtraDataFromFile (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/Engines/JavaScript.js:94:15)
        at async Template.getFrontMatterData (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/TemplateContent.js:132:21)
        at async Template.getData (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/Template.js:212:29)
        at async Template.getTemplateMapEntries (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/Template.js:681:16)
        at async TemplateMap.add (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/TemplateMap.js:32:21)
        at async Promise.all (index 1612)
        at async TemplateWriter._createTemplateMap (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/TemplateWriter.js:132:5)
        at async TemplateWriter.write (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/TemplateWriter.js:168:5)
        at async Eleventy.write (/Users/<me>/programs/personal-site/node_modules/@11ty/eleventy/src/Eleventy.js:659:13)

Expected behavior
The site would build with all templates copied over.

Environment:

  • OS and Version: macOS 10.15.3
  • Eleventy Version: 0.10.0

Additional context
I have an .eleventyignore file in my project root as well (files are not duplicated between them). I tried listing the .gitignore file there, but it did not seem to make a difference.

needs-triage

Most helpful comment

This is resolved in 0.11 already. It鈥檚 a problem with the npm package itself.

All 4 comments

https://www.11ty.dev/docs/ignores/#opt-out-of-using-.gitignore

eleventyConfig.setUseGitIgnore(false);

But the docs link above has some good info on .gitignore vs .eleventyignore vs node_modules, so definitely worth a quick read.

I also had this issue and was pretty bewildered until I landed here. Would it be possible to add a friendly prompt in the error message?

This is resolved in 0.11 already. It鈥檚 a problem with the npm package itself.

As @stevenpetryk mentioned above, it looks like this was indeed fixed. I just upgraded to v0.11 and can confirm I'm no longer seeing this problem. Thanks!

Also, not sure if the issue should be documented as part of this milestone.

Was this page helpful?
0 / 5 - 0 ratings