I am just getting started, and running 'eleventy' kept giving me this error:
(node:1800) UnhandledPromiseRejectionWarning: #<EleventyError>
(node:1800) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1800) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
What are some things I can try?
Oh! Well, that鈥檚 no good! Did you try debug mode? https://github.com/11ty/eleventy/#debugging
Run DEBUG=Eleventy* eleventy and it鈥檒l spit out a bunch of stuff you can add here!
What鈥檚 your directory structure / .eleventy.js config file look like?
No matter what鈥檚 happening here we need better error handling and messaging.
My thoughts on this are to throw errors everywhere and catch them all in the root index file.
I have been trying a few different things. Right now this is what my .eleventy.js looks like, and it's working fine right now:
module.exports = {
dir: {
input: "src",
data: "_data"
},
templateFormats: ['pug','md', 'css', 'eot', 'svg', 'ttf', 'woff', 'png'],
};
When I pass in eleventyConfig like this though:
module.exports = function(eleventyConfig) {
return {
templateFormats: ['pug','md', 'css', 'eot', 'svg', 'ttf', 'woff', 'png'],
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site"
}C
};
};
it will then give me an error:
Error: TemplateLayout directory does not exist for layout.pug: ./_includes
My directory structure looks like
/project
/src
/_data
/_includes
/layout.pug
/assets
/css
index.pug
eleventy.js
module.exports = function(eleventyConfig) {
return {
templateFormats: ['pug','md', 'css', 'eot', 'svg', 'ttf', 'woff', 'png'],
dir: {
input: ".",
includes: "_includes",
data: "_data",
output: "_site"
}C
};
};
I鈥檓 gonna assume that C is not there on your local?
Regardless, I don鈥檛 think the dir鈥檚 in your second example match the first? I think you want this:
module.exports = function(eleventyConfig) {
return {
templateFormats: ['pug','md', 'css', 'eot', 'svg', 'ttf', 'woff', 'png'],
dir: {
input: "src",
}
};
};
All the others are default and don鈥檛 need overrides. This will resolve to:
"src""src/_includes""src/_data""_site"Does that make sense?
Another thing that might simplify it for you is to use a directory passthrough copy instead of all of those template formats:
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("src/css");
return {
templateFormats: ['pug','md'],
dir: {
input: "src",
}
};
};
ahh right, nice spot, and I will take note of passthrough.
Thank you so much for the help!
I鈥檝e started seeing this error too (although I don鈥檛 know if this was happening before and I missed it, or something has changed to have it start happening). Here is the error, within the context of the debug output:
Dev:Eleventy:Template new Template('./src/_indices/archives.liquid') +0ms
Dev:Eleventy:Template './src/_indices/archives.liquid' getMapped() +5ms
Dev:Eleventy:Template './src/_indices/archives.liquid' getData() +1ms
Dev:Eleventy:TemplateData getLocalDataPaths('./src/_indices/archives.liquid') +0ms
Dev:Eleventy:TemplateData parsed.dir: './src/_indices' +0ms
Dev:Eleventy:TemplateData allDirs: [ './src/_indices', './src' ] +0ms
Dev:Eleventy:TemplateData dirStr: './src/_indices'; inputDir: './src' +0ms
Dev:Eleventy:TemplateData dirStr: './src'; inputDir: './src' +0ms
Eleventy:TemplateData getLocalDataPaths('./src/_indices/archives.liquid'): [ './src/_indices/archives.json', './src/_indices/_indices.json' ] +135ms
(node:42087) UnhandledPromiseRejectionWarning: #<EleventyError>
(node:42087) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:42087) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Ah ha! I鈥檝e found out what I did! I changed the name of my assets folder from assets to _assets, but hadn鈥檛 updated this line in my 11ty config:
eleventyConfig.addPassthroughCopy('src/assets');
Correcting the folder name meant this error went away.
Looks like this will improve with some of the changes in #112.
Okay, this will be included with The Next Minor Version after v0.3.5