Hi,
I use the Programmatic API (v2.beta.20 & v2.beta.24) and I added the following from your example:
const dev = process.env.NODE_ENV !== 'production';
const dir = process.cwd();
const app = next({ dev, dir });
The server is running, but on any request it gives me the following error:
Client side it's an 500 error: Internal Server error
In the logs, I have:
glob error { Error: EACCES: permission denied, scandir '/var' errno: -13, code: 'EACCES', syscall: 'scandir', path: '/var' }
/var is the root folder on Openshift which I don't have access to.
I don't see why Next is looking for that folder because I have set up the next.dir accordingly.
@kadiks could you check process.cwd()? We don't look for /var anywhere in the next.js code
I even did it on the app instance and the value is fine:
console.log('server.js app.dir', app.dir); // server.js app.dir /var/lib/openshift/xxxx/app-root/runtime/repo
Is there a place where Next look into the root folder?
It is related to permissions.
The glob module fails because it cannot even ls on the /var folder (unlike Heroku where it's possible)
I didn't fix it, but it has nothing to do with Next.JS
Same problem in termux(android) and ubuntu when changing filesystem root permissions (EACCES: permission denied, scandir '/').
I think it could be fixed calling glob-promise with nocase: false when on linux (platform === 'linux' || platform === 'android'). Or maybe catching the EACCES error and trying with nocase: false.
https://github.com/zeit/next.js/blob/443b1d1260bda7a91fb797ca04b94c55ddb91a98/server/resolve.js#L82
Hello!
I had the same problem as @Wesitos - and his fix helped to run the build (thanks again mate)!
My server is freeBSD-based, and it seems every time I would like to set up an app, it will be necessary to manually correct the _nocase_ value to _false_. Do you think there's any, "less-dirty" solution?
Thanks @Wesitos for your solution . it's works for dev mode
But for const app = next({dev: false, dir: process.cwd()}) I received the following error :
{ Error: Cannot find module 'next\dist\lib\error.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/*****/public_html/.next/dist/pages/_error.js:3:18)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3) code: 'MODULE_NOT_FOUND' }
what's the problem?
my server.js config:
const next = require('next');
const routes = require('./routes');
const app = next({dev: false, dir: process.cwd()});
const handler = routes.getRequestHandler(app);
var compression = require('compression');
var express = require('express');
app.prepare().then(() => {
express().use(compression()).use(handler).listen(3000);
});
Most helpful comment
Same problem in termux(android) and ubuntu when changing filesystem root permissions (
EACCES: permission denied, scandir '/').I think it could be fixed calling
glob-promisewithnocase: falsewhen on linux (platform === 'linux' || platform === 'android'). Or maybe catching theEACCESerror and trying withnocase: false.https://github.com/zeit/next.js/blob/443b1d1260bda7a91fb797ca04b94c55ddb91a98/server/resolve.js#L82