11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.29k stars 496 forks source link

Error: ENOENT: no such file or directory, open #398

Closed andreapernici closed 5 years ago

andreapernici commented 5 years ago

I get the following error. Looks like it got errors during the file inclusion, but obviously files are there and it print out the source of the file, but don't processo the files.

[eleventy@eventi eleventy-ast]$ npx eleventy
Error writing templates: (full stack in DEBUG output)
> Having trouble writing template: _site/ciao/index.html (TemplateWriterWriteError)
> (unknown path)
  Template render error: (/home/eleventy/static-generators/eleventy-ast/_includes/head.njk)
  Error: ENOENT: no such file or directory, open '/**
 * Copyright 2015 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* eslint-env browser */
'use strict';
kleinfreund commented 5 years ago

Can you show us where you include head.njk? It looks like Eleventy gets the content of a file instead of a file path.

Also, @zachleat, the Template render error should report more information. Like this, you can’t necessarily track down from where the error is thrown.

andreapernici commented 5 years ago

It's pretty odd the situation.

I have 2 identical project in 2 different folder and I get the error only on one project.

The head.njk file is located in _includes The base.njk file including head.njk is located in _includes/layouts/ The printed output of the js file is simply a variable set to inline the js that is in _includes/inline-js/

The error happens here.


{% set sw %}{% include "inline-js/service-worker-registration.js" %}{% endset %}
{% set ga %}{% include "inline-js/googleanalytics.js" %}{% endset %}
{% set fb %}{% include "inline-js/facebookpixel.js" %}{% endset %}
{% set tw %}{% include "inline-js/twitteruniversaltag.js" %}{% endset %}
{% set carrelletto %}{% include "inline-js/carrelletto.js" %}{% endset %}
{% set videojs %}{% include "inline-js/fascia-video.njk" %}{% endset %}
<script>{{ sw | jsmin | safe }}{{ ga | jsmin | safe }}{{ fb | jsmin | safe }}{{ tw | jsmin | safe }}{{ carrelletto | jsmin | safe }} </script>

If I remove the sets the error skip till the next file footer.njk including other sets....

Is like it is messing up with paths, but using DEBUG I don't get any additional info on the error.

andreapernici commented 5 years ago

Just to be more clearer the project where I got those errors happens only on my remote installation. Locally to other team members it works.

zachleat commented 5 years ago

Hmm, I think we're going to need a better test case here. From the original error it seems to be trying to include the files contents rather than a path to the file? But it doesn't seem obvious to me why it would be doing that from the code sample you provided.

andreapernici commented 5 years ago

Yes is pretty strange cause this happen only on a Server where another instance of eleventy is running without any issue and with the same code.

Looks weird.

Maybe it depends by a global eleventy installation? I'm on Centos 7

zachleat commented 5 years ago

I guess I had a couple ideas here that might be worth trying:

  1. Check whether the order of your filters matters: {{ fb | jsmin | safe }}
  2. Check whether or not your .js files have accidental nunjucks content in them e.g. {{
  3. Moreso, I’m not sure if include is supposed to be used on .js files like this. As https://mozilla.github.io/nunjucks/templating.html#include states it does a full Nunjucks render on the included content.
zachleat commented 5 years ago
  1. Try removing the ga include and see if it fails or succeeds.
thecristen commented 5 years ago

I got this error too. Not sure why. But deleting the _site folder and building again seems to have fixed it.

zachleat commented 5 years ago

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and I will reopen the issue. Thanks!