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

Deploying next.js app fails with UnhandledPromiseRejectionWarning #175

Closed
backflip opened this issue Dec 17, 2016 · 12 comments
Closed

Deploying next.js app fails with UnhandledPromiseRejectionWarning #175

backflip opened this issue Dec 17, 2016 · 12 comments

Comments

@backflip
Copy link

backflip commented Dec 17, 2016

I'm trying to deploy the current GitHub version of next.js. In order to work around the fact the the dist folder is missing on GitHub, I have forked the repo and added these files: https://github.com/backflip/next.js/tree/release

However, npm start fails with a (node:275) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: EACCES: permission denied, rmdir '/home/nowuser/src/.next'.

Could this be related to the warnings/errors further above regarding node-pre-gyp (which is connected to the recent addition of chokidar to next.js)?

> ▲ npm install
> Installing package next@git://github.com/backflip/next.js.git#c5851e07fe5fca8260033987ff82f22b74bd1e72
> Installing package path-match@^1.2.4
> Installing package query-string@^4.2.3
> Installing package restify@^4.3.0
> Installing package url@^0.11.0
> Installing package eslint@^3.10.2
> Installing package eslint-config-standard@^6.2.1
> Installing package eslint-plugin-promise@^3.4.0
> Installing package eslint-plugin-react@^6.8.0
> Installing package eslint-plugin-standard@^2.0.1
> (node:49) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, readlink '/home/nowuser/src/node_modules/.tmp/6bc0d960-7e74-4d87-92a4-e40e03c29164/node_modules/node-pre-gyp'
> (node:49) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
> node-pre-gyp info it worked if it ends with ok
> node-pre-gyp info using node-pre-gyp@0.6.29
> node-pre-gyp info using node@7.0.0 | linux | x64
> node-pre-gyp info check checked for "/home/nowuser/src/node_modules/dc1ba8196115775facd8a7e77d3b9c0387eea5f3/lib/binding/Release/node-v51-linux-x64/fse.node" (not found)
> node-pre-gyp http GET https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v51-linux-x64.tar.gz
> node-pre-gyp http 404 https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v51-linux-x64.tar.gz
> node-pre-gyp ERR! Tried to download: https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v51-linux-x64.tar.gz 
> node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.0.15 and node@7.0.0 (node-v51 ABI) (falling back to source compile with node-gyp) 
> node-pre-gyp http Pre-built binary not available for your system, looked for https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v51-linux-x64.tar.gz 
> gyp info it worked if it ends with ok
> gyp info using node-gyp@3.3.1
> gyp info using node@7.0.0 | linux | x64
> gyp info ok 
> gyp info it worked if it ends with ok
> gyp info using node-gyp@3.3.1
> gyp info using node@7.0.0 | linux | x64
> gyp http GET https://nodejs.org/download/release/v7.0.0/node-v7.0.0-headers.tar.gz
> gyp http 200 https://nodejs.org/download/release/v7.0.0/node-v7.0.0-headers.tar.gz
> gyp http GET https://nodejs.org/download/release/v7.0.0/SHASUMS256.txt
> gyp http 200 https://nodejs.org/download/release/v7.0.0/SHASUMS256.txt
> gyp info spawn /usr/bin/python2
> gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
> gyp info spawn args   'binding.gyp',
> gyp info spawn args   '-f',
> gyp info spawn args   'make',
> gyp info spawn args   '-I',
> gyp info spawn args   '/home/nowuser/src/node_modules/dc1ba8196115775facd8a7e77d3b9c0387eea5f3/build/config.gypi',
> gyp info spawn args   '-I',
> gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
> gyp info spawn args   '-I',
> gyp info spawn args   '/home/nowuser/.node-gyp/7.0.0/include/node/common.gypi',
> gyp info spawn args   '-Dlibrary=shared_library',
> gyp info spawn args   '-Dvisibility=default',
> gyp info spawn args   '-Dnode_root_dir=/home/nowuser/.node-gyp/7.0.0',
> gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
> gyp info spawn args   '-Dnode_lib_file=node.lib',
> gyp info spawn args   '-Dmodule_root_dir=/home/nowuser/src/node_modules/dc1ba8196115775facd8a7e77d3b9c0387eea5f3',
> gyp info spawn args   '--depth=.',
> gyp info spawn args   '--no-parallel',
> gyp info spawn args   '--generator-output',
> gyp info spawn args   'build',
> gyp info spawn args   '-Goutput_dir=.' ]
> gyp info ok 
> gyp info it worked if it ends with ok
> gyp info using node-gyp@3.3.1
> gyp info using node@7.0.0 | linux | x64
> gyp info spawn make
> make: Entering directory '/home/nowuser/src/node_modules/dc1ba8196115775facd8a7e77d3b9c0387eea5f3/build'
>   SOLINK_MODULE(target) Release/obj.target/.node
> gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
>   COPY Release/.node
> make: Leaving directory '/home/nowuser/src/node_modules/dc1ba8196115775facd8a7e77d3b9c0387eea5f3/build'
> gyp info ok 
> node-pre-gyp info ok 
> ▲ npm run build
> build exited with status 0
> ▲ npm start
> (node:275) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: EACCES: permission denied, rmdir '/home/nowuser/src/.next'
> (node:275) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@jamo
Copy link
Contributor

jamo commented Dec 17, 2016

The error message Error: EACCES: permission denied, rmdir '/home/nowuser/src/.next' makes me wonder if next build and next start are run in npm run build and npm run start

@rauchg
Copy link
Member

rauchg commented Dec 17, 2016

Yep. Make sure you alter the filesystem in the build step. Otherwise you can only write to /tmp

@backflip
Copy link
Author

backflip commented Dec 17, 2016

The build step seems to run fine (> build exited with status 0).

Looks like it has to do with the start script:

"scripts": {
    "dev": "next",
    "build": "next build",
    "start": "node index.js",
    "deploy": "now -e NODE_ENV=production",
    "lint": "eslint ."
}

When I change this back to next start (using the default server instead of a custom one), it works fine.

So there seems to be a difference on how the custom server works my local machine (OS X 10.12, Node 7.0.0) and on now.sh.

My index.js:

const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')
const pathMatch = require('path-match')

const app = next({ dev: true })
const handle = app.getRequestHandler()
const route = pathMatch()
const match = route('/wine/:id')

app.prepare().then(() => {
  createServer((req, res) => {
    const { pathname } = parse(req.url)
    const params = match(pathname)

    if (params === false) {
      handle(req, res)

      return
    }

    app.render(req, res, '/wine', params)
  }).listen(3000, (err) => {
    if (err) throw err

    console.log('> Ready on http://localhost:3000')
  })
})

Is this something I could work around by "altering the filesystem", @rauchg? Could you give me a hint there?

@backflip
Copy link
Author

backflip commented Dec 17, 2016

Argh, it works fine if I remove dev: true from the next() call (or rather set it to dev: (process.env.NODE_ENV !== 'production') instead). Sorry about that. I should have probably waited for the upcoming docs on using a custom router. :)

/cc @nkzawa

@carcinocron
Copy link

Yep. Make sure you alter the filesystem in the build step. Otherwise you can only write to /tmp

What do you mean by "alter the filesystem" in the context of zeit now?

I'm having the same error:

> [nuxt] Building done
> ▲ npm start
> > link-queue@0.0.0 prestart /home/nowuser/src
> > npm run build
> > link-queue@0.0.0 build /home/nowuser/src
> > nuxt build
> [nuxt] Building...
> Tue, 16 May 2017 23:00:52 GMT nuxt:build App root: /home/nowuser/src
> Tue, 16 May 2017 23:00:52 GMT nuxt:build Generating .nuxt/ files...
> { Error: EACCES: permission denied, rmdir '/home/nowuser/src/.nuxt'
>   errno: -13,
>   code: 'EACCES',
>   syscall: 'rmdir',
>   path: '/home/nowuser/src/.nuxt' }

@jamo
Copy link
Contributor

jamo commented May 16, 2017

What do you mean by "alter the filesystem" in the context of zeit now?

To write data to the disk (expect temporary files to /tmp)

Try running the build in the build step...

@carcinocron
Copy link

npm run build works locally.

  "scripts": {
    "build": "nuxt build",
    "dev": "DEBUG=nuxt:* nodemon --watch src/ --watch config/ --exec ./node_modules/babel-cli/bin/babel-node.js -- ./src/index.js",
    "prestart": "npm run build",
    "start": "NODE_ENV=production ./node_modules/babel-cli/bin/babel-node.js ./src/index.js",
    "test": "npm run eslint && npm run mocha"
  },

It looks like it's crashing when running npm run build on zeit now, so I don't think it's because I'm not running build. I've changed my assumption that I'm suppose to run npm run build && now instead of only now. I also noticed the default config for production had "PORT" as the port, which I also changed to "8000". It appears that it's building again anyways, which does not make sense to me.

Also this message might be part of the problem.

> Warning! Skipping file ~/.nuxt/dist/server-bundle.json (size exceeded 1MB)
> Warning! 1 of the files exceeded the limit for your plan.
> Please run `now upgrade` to upgrade.

Maybe it's rebuilding because that file is missing. I'll probably need to figure out how to split that file first.

@jasondonnette
Copy link

jasondonnette commented Nov 21, 2017

I ran into the same problem using transform-inline-environment-variables in babel.

eg:

"env": {
    "development": {
      "plugins": ["inline-dotenv"]
    },
    "production": {
      "plugins": ["transform-inline-environment-variables"]
    }
  },

(as seen in the example https://github.com/zeit/next.js/blob/canary/examples/with-dotenv/.babelrc)

The issue was caused by using

const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });

in the /index.js file since it's not transpiled by babel. Switching it to:

const dev = process.env.NODE_ENV === 'development';
const app = next({ dev });

works for Now.

@sachalifs
Copy link

I was having the same issue with my server.js:

const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')
const { join } = require('path')

const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

async function start() {
  try {
    await app.prepare()
    createServer((req, res) => {
      const parsedUrl = parse(req.url, true)
      const rootStaticFiles = [
        '/robots.txt',
        '/sitemap.xml',
        '/favicon.ico'
      ]
      if (rootStaticFiles.indexOf(parsedUrl.pathname) > -1) {
        const path = join(__dirname, 'static', parsedUrl.pathname)
        app.serveStatic(req, res, path)
      } else {
        handle(req, res, parsedUrl)
      }
    })
    .listen(port, (err) => {
      if (err) throw err
      console.log(`> Ready on http://localhost:${port}`)
    })
  } catch (err) {
    console.log(err)
  }
}

start()

I fixed this prepending NODE_ENV=production to the start script:

  ...
  "scripts": {
    "build": "next build",
    "dev": "node server",
    "start": "NODE_ENV=production node server"
  },
  ...

@joemulick
Copy link

joemulick commented Dec 1, 2017

I was getting a BUILD_ERROR from Error: EACCES: permission denied, rmdir '/home/nowuser/src/.next'

The above suggestion of adding

start": "NODE_ENV=production node server

to the scripts in the package json fixed the issue for me

timneutkens added a commit to timneutkens/next.js that referenced this issue Dec 2, 2017
timneutkens added a commit to vercel/next.js that referenced this issue Dec 2, 2017
* Add check for writeable directory

Followup of vercel/vercel#175

* Add link to docs
@Vadorequest
Copy link

I got into this issue by using Serverless and compiling my code in development mode, which automatically enabled HMR, which tried to write stuff on the disk, which failed because .next/ isn't writable. Using another environment/stage did the trick for me too.

"deploy:staging": "cross-env-shell NODE_ENV=staging \"npm run build:staging && serverless deploy\"",

@debaosuidecl
Copy link

Please I am building a mock authentication project

and I am having the same problem
` WARN! You are using an old version of the Now Platform. More: https://zeit.co/docs/v1-upgrade

Deploying ~\Documents\next-cookie-auth under debaosuidecl@gmail.com
Synced 1 file (646B) [2s]
Using Node.js 8.11.3 (default)
https://next-cookie-auth-wfiickyjrl.now.sh [v1] [in clipboard] (bru1) [15s]
Building…
▲ npm install
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/kind-of-7323ef0a/package.json'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/kind-of-7323ef0a/README.md'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/kind-of-7323ef0a/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/kind-of-7323ef0a/index.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/source-map-support-d88a4c82/LICENSE.md'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/source-map-support-d88a4c82/README.md'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/source-map-support-d88a4c82/register.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/source-map-support-d88a4c82/source-map-support.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/source-map-fb98f94d/lib/read-wasm.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/source-map-fb98f94d/lib/source-map-consumer.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/generateTypeHelpers.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/generators'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/utils'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/asserts/assertNode.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/asserts/generated'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/builder.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/flow'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/generated'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/react'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/clone/clone.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/clone/cloneDeep.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/clone/cloneNode.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/clone/cloneWithoutLoc.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/addComment.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/addComments.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/inheritInnerComments.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/inheritLeadingComments.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/inheritTrailingComments.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/inheritsComments.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/comments/removeComments.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/constants/generated'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/constants/index.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/ensureBlock.js'> npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/gatherSequenceExpressions.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toBindingIdentifierName.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toBlock.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toComputedKey.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toExpression.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toIdentifier.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/react-dom-b464b929/umd/react-dom.production.min.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toKeyAlias.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toSequenceExpression.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/toStatement.js'> npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/converters/valueToNode.js'> npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/core.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/es2015.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/experimental.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/flow.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/index.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/jsx.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/misc.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/typescript.js'> npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/definitions/utils.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/appendToMemberExpression.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/flow'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/is.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/inherits.js'> npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/prependToMemberExpression.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/removeProperties.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/removePropertiesDeep.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/retrievers/getBindingIdentifiers.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/retrievers/getOuterBindingIdentifiers.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/traverse/traverse.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/traverse/traverseFast.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/utils/inherit.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/utils/react'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/utils/shallowEqual.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/buildMatchMemberExpression.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/generated'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isBinding.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isBlockScoped.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isImmutable.js'> npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isLet.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isNode.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isNodesEquivalent.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isReferenced.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isScope.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isSpecifierDefault.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isType.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isValidES3Identifier.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isValidIdentifier.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/isVar.js'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/matchesPattern.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/react'
npm WARN tar ENOENT: no such file or directory, open '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/validate.js'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/generators'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/generators'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/generators'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/generators'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/utils'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/utils'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/scripts/utils'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/asserts/generated'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/flow'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/flow'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/generated'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/builders/react'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/constants/generated'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/modifications/flow'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/utils/react'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/generated'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/react'
npm WARN tar ENOENT: no such file or directory, lstat '/home/nowuser/src/node_modules/.staging/@babel/types-fb510155/lib/validators/react'
npm WARN next-cookie-auth@1.0.0 No repository field.

npm ERR! code E404
npm ERR! 404 Not Found: event-stream@https://registry.npmjs.org/event-stream/-/event-stream-3.3.6.tgz

npm ERR! A complete log of this run can be found in:
npm ERR! /home/nowuser/.npm/_logs/2018-12-14T07_43_56_205Z-debug.log
Error! Build failed
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! next-cookie-auth@1.0.0 deploy: set NODE_ENV=production && now --public
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the next-cookie-auth@1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\OSUIDE O.C\AppData\Roaming\npm-cache_logs\2018-12-14T07_44_00_605Z-debug.log`

my server.js looks like this:

`const next = require('next');
const cookieParser = require ('cookie-parser')
const express = require('express');
const axios = require('axios')

const dev = process.env.NODE_ENV !== 'production';
const port = process.env.PORT || 3000;
const app = next ({dev})
const handle = app.getRequestHandler();
const AUTH_USER_TYPE = "authenticated"
const COOKIE_SECRET = "mysupersecret"
const COOKIE_OPTIONS = {
httpOnly: true,
secure: !dev,
signed: true
}

const authenticate = async(email, password)=> {
const {data} = await axios.get('https://jsonplaceholder.typicode.com/users')

return data.find(user=> {
if (user.email === email && user.website === password){
return user;
}
}
)
}

app.prepare().then(()=>{
const server = express();
server.use(express.json());
server.use(cookieParser(COOKIE_SECRET));
server.post('/api/login', async (req, res)=> {
const { email, password } = req.body;
const user = await authenticate(email,password);
if(!user){
return res.status(403).send("Invalid email or password")
}
const userData = {
name : user.name,
email: user.email,
type: AUTH_USER_TYPE
}
res.cookie('token', userData, COOKIE_OPTIONS)
res.json(userData)
})

server.post('/api/logout', (req, res)=> {
    res.clearCookie('token', COOKIE_OPTIONS);
    res.sendStatus(204)// no content
})

server.get('/api/profile', async (req, res)=> {
    const {signedCookies = {} } = req;
    const { token } = signedCookies;
    if (token && token.email){
      const {data} = await axios.get('https://jsonplaceholder.typicode.com/users')
      const userProfile =   data.find(user=> user.email === token.email)
      return res.json({user: userProfile})
    }
    res.sendStatus(404);
})

server.get('*', (req, res)=> {
    return handle(req, res);
})

server.listen(port, (err)=>{
    if (err) throw err;
    console.log (`listening on PORT ${port}`)
} )

})`

my package.json

{
"name": "next-cookie-auth",
"version": "1.0.0",
"description": "Cookie authentication with Next.js",
"main": "server.js",
"scripts": {
"dev": "nodemon server.js",
"start": "set NODE_ENV=production && node server.js",
"build": "next build",
"deploy": "set NODE_ENV=production && now --public"
},
"author": "Deba Osuide",
"license": "ISC",
"dependencies": {
"axios": "^0.18.0",
"cookie-parser": "^1.4.3",
"express": "^4.16.4",
"next": "^7.0.2",
"react": "^16.6.3",
"react-dom": "^16.6.3"
},
"devDependencies": {
"nodemon": "^1.18.5"
},
"directories": {
"lib": "lib"
}
}

it runs fine in development ofcourse but I cant deploy keeps giving me that nasty error;
help me please

TooTallNate pushed a commit that referenced this issue Aug 23, 2019
* Fix broken error link

* Added legacy mode error

Standard "Next.js" for all citations of Next.
Add "Legacy Mode" error.

* Update no serverless pages built doc

* Update doc on now/next legacy mode

* Add link after the error message
TopDeveloper705 pushed a commit to TopDeveloper705/next.js-template-project that referenced this issue Dec 11, 2022
* Add check for writeable directory

Followup of vercel/vercel#175

* Add link to docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants