Permissions issue preventing Next.js from working?


#1

It seems like apps that use Next.js are currently incompatible with Glitch due to a permissions issue. See https://glitch.com/edit/#!/wistia-next-app for example. That’s pretty much just the create-next-app example (https://github.com/segmentio/create-next-app) with one component added and some boilerplate content removed.

Here’s what happens when I try to build the app from the Glitch console:

$ npm run build
> create-next-example-app@ build /app
> next build
> Using "webpack" config function defined in next.config.js.
> Failed to build on /etc/service/watcher/960bcb8c-388d-4d18-a72e-fbded320c268
{ Error: EACCES: permission denied, mkdir '/etc/service/watcher/960bcb8c-388d-4d18-a72e-fbded320c268/.next'
    at Error (native)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/etc/service/watcher/960bcb8c-388d-4d18-a72e-fbded320c268/.next' }
npm ERR! Linux 4.4.0-1018-aws
npm ERR! argv "/home/nvm/.nvm/versions/node/v6.11.2/bin/node" "/home/nvm/.nvm/versions/node/v6.11.2/bin/npm" "run" "build"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! create-next-example-app@ build: `next build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the create-next-example-app@ build script 'next build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the create-next-example-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     next build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs create-next-example-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls create-next-example-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /app/npm-debug.log

#2

Hi David,

there is a bug somewhere in node/npm (I can’t find the GitHub issue right now) which causes TMP_DIR to be set in the wrong way. Try issuing export TMP_DIR=/tmp before npm run build, or run TMP_DIR=/tmp npm run build directly. It should solve your issue :slight_smile:

Let us know what happens!


#3

Hey, thanks for the quick reply! Just tried that but there was no change… then I tried printenv to make sure the environment variable got set properly, and noticed that there’s a variable called TMPDIR (same thing just without the _) set to /etc/service/watcher. So I tried setting that to /tmp, and… now npm run build seems to work OK (no errors at least), but npm run start is angry:

app@wistia-next-app:~ 13:42 
$ npm run build

> create-next-example-app@ build /app
> next build
> Using "webpack" config function defined in next.config.js.
app@wistia-next-app:~ 13:42 
$ npm run start
> create-next-example-app@ start /app
> next start
{ Error: listen EADDRINUSE :::3000
    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at Server._listen2 (net.js:1258:14)
    at listen (net.js:1294:10)
    at Server.listen (net.js:1390:5)
    at /app/node_modules/next/dist/server/index.js:757:31
    at Promise.F (/app/node_modules/core-js/library/modules/_export.js:35:28)
    at Server._callee15$ (/app/node_modules/next/dist/server/index.js:751:24)
    at tryCatch (/app/node_modules/regenerator-runtime/runtime.js:65:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/app/node_modules/regenerator-runtime/runtime.js:303:22)
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 3000 }
npm ERR! Linux 4.4.0-1018-aws
npm ERR! argv "/home/nvm/.nvm/versions/node/v6.11.2/bin/node" "/home/nvm/.nvm/versions/node/v6.11.2/bin/npm" "run" "start"
npm ERR! node v6.11.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! create-next-example-app@ start: `next start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the create-next-example-app@ start script 'next start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the create-next-example-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     next start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs create-next-example-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls create-next-example-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /app/npm-debug.log

Any ideas? Was changing TMPDIR a bad idea on my part? Thanks for your help!


#4

This looks like it might be the issue you were thinking of btw: https://github.com/npm/npm/issues/4531


#5

You’re right, it’s TMPDIR, not TMP_DIR.

As for why npm run start is not working, it’s because glitch starts the application on your behalf (npm run start is called automatically by the Glitch watcher), this is why you see the error EADDRINUSE (address/port in use): the application is already running and listening on port 3000 :slight_smile:


#6

Oh hey, look at that! We good. Thanks so much! :raised_hands: :flags: :rocket: