Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andreapernici opened this issue Feb 1, 2019 · 9 comments
Closed

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

andreapernici opened this issue Feb 1, 2019 · 9 comments
Labels
stale Closed (manually) after waiting on a response for 30 days.

Comments

@andreapernici
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

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.

@zachleat zachleat added the needs-test-case Please submit a reproducible test case showcasing the issue! label Feb 17, 2019
@andreapernici
Copy link
Author

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
Copy link
Member

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
Copy link
Member

  1. Try removing the ga include and see if it fails or succeeds.

zachleat added a commit that referenced this issue Mar 23, 2019
@thecristen
Copy link

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

@zachleat zachleat added stale Closed (manually) after waiting on a response for 30 days. and removed needs-test-case Please submit a reproducible test case showcasing the issue! labels Jun 15, 2019
@zachleat
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Closed (manually) after waiting on a response for 30 days.
Projects
None yet
Development

No branches or pull requests

4 participants