Content: WARN /var/www/html/site.com/content does not exist, but it does

Created on 30 May 2020  路  1Comment  路  Source: nuxt/content

Version

@nuxt/content: v1.2.0
nuxt: v2.12.2
Ubuntu: 18.04

Not sure if this is a bug, or where it's coming from. I've been working on a site using @nuxt/content on my localhost, which has been great. But when I migrated everything to live, suddenly I was getting the error WARN /var/www/html/dev.site.com/content does not exist. I can see the /content folder when I ssh in, it has all its files, and it's got drwxr-xr-x permissions. This is happening regardless of whether I'm running nuxt start or nuxt.

As far as my server setup, I'm using nginx as a reverse proxy as shown on the docs. My server_name is currently set to an IP address, since I haven't transferred the domain name over yet. All the files are getting auto-updated via the post-receive hook in git, but I can confirm that all the files inside the /content folder are there. I can also see all the components contained in /layouts/default.vue correctly, it's just /content that apparently doesn't exist.

I don't currently have the site running through https, because I'm trying to fix this part first.

Any ideas?

Edit: here's my nginx config, in case that helps. It's essentially identical to what's on the nuxt.js website right now.

map $sent_http_content_type $expires {
        "text/html"                     epoch;
        "text/html; charset=utf-8"      epoch;
        default                         off;
}

server {
        listen 80;
        server_name xx.xx.xxx.xx;

        gzip                    on;
        gzip_types              text/plain application/xml text/css application/javascript;
        gzip_min_length         1000;

        location / {
                expires $expires;
                proxy_redirect                  off;
                proxy_set_header Host           $host;
                proxy_set_header X-Real-IP      $remote_addr;
                proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto      $scheme;
                proxy_read_timeout              1m;
                proxy_connect_timeout           1m;
                proxy_pass                      http://127.0.0.1:3001;
        }
}
bug

Most helpful comment

What a rabbit hole! It turns out the problem was the version of node on my server, which was at 8.x.x instead of ^10.x.x. 8.x doesn't support promises in fs, so the call to fs.readdir was failing because readdir didn't exist.

However, I do think the error message in this line should at least contain a stack trace, as the idea of /content not existing is pretty game-breaking if you're relying on this plugin for... well, content. I don't know if checking for the right node version would also be appropriate, since the issue I encountered was totally unrelated to the folder existing.

And if you're someone encountering this issue: use nvm to update to something recent, use nvm default alias x.xx.x to set the version to something sane. If you were relying on git hooks to rebuild your nuxt app on a remote server, you also need to throw in the two bash lines described in nvm's install script section. Otherwise, you'll keep getting your old version every time git ssh's in.

>All comments

What a rabbit hole! It turns out the problem was the version of node on my server, which was at 8.x.x instead of ^10.x.x. 8.x doesn't support promises in fs, so the call to fs.readdir was failing because readdir didn't exist.

However, I do think the error message in this line should at least contain a stack trace, as the idea of /content not existing is pretty game-breaking if you're relying on this plugin for... well, content. I don't know if checking for the right node version would also be appropriate, since the issue I encountered was totally unrelated to the folder existing.

And if you're someone encountering this issue: use nvm to update to something recent, use nvm default alias x.xx.x to set the version to something sane. If you were relying on git hooks to rebuild your nuxt app on a remote server, you also need to throw in the two bash lines described in nvm's install script section. Otherwise, you'll keep getting your old version every time git ssh's in.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pi0 picture pi0  路  3Comments

Rednas83 picture Rednas83  路  3Comments

mathieunicolas picture mathieunicolas  路  4Comments

uporot1k picture uporot1k  路  4Comments

haykokalipsis picture haykokalipsis  路  4Comments