dwyl / hapi-auth-jwt2

:lock: Secure Hapi.js authentication plugin using JSON Web Tokens (JWT) in Headers, URL or Cookies
ISC License
798 stars 126 forks source link

README - Quick Demo don't work out of the box #348

Closed raunakkathuria closed 4 years ago

raunakkathuria commented 4 years ago

Followed the steps listed on https://github.com/dwyl/hapi-auth-jwt2#quick-demo and get the following error

/home/raunakkathuria/Documents/technical/hapi-auth-jwt2/node_modules/@hapi/hapi/lib/core.js:51
    actives = new WeakMap();                                                   // Active requests being processed
            ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:721:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/raunakkathuria/Documents/technical/hapi-auth-jwt2/node_modules/@hapi/hapi/lib/server.js:9:14)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)

And also, as per the hapi documentation the server is created with const server = new Hapi.server({ port: 8000 }); - lowercase s in server - but in your README it's stated as const server = new Hapi.Server({ port: 8000 }); - capital s

Can we specifically highlight this difference? And, is this expected?


Also, ran npm run quick and this is the debug log file content

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'quick' ]
2 info using npm@6.14.4
3 info using node@v10.16.0
4 verbose run-script [ 'prequick', 'quick', 'postquick' ]
5 info lifecycle hapi-auth-jwt2@10.0.0~prequick: hapi-auth-jwt2@10.0.0
6 info lifecycle hapi-auth-jwt2@10.0.0~quick: hapi-auth-jwt2@10.0.0
7 verbose lifecycle hapi-auth-jwt2@10.0.0~quick: unsafe-perm in lifecycle true
8 verbose lifecycle hapi-auth-jwt2@10.0.0~quick: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/raunakkathuria/Documents/technical/hapi-auth-jwt2/node_modules/.bin:/home/raunakkathuria/bin:/home/raunakkathuria/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/mssql-tools/bin
9 verbose lifecycle hapi-auth-jwt2@10.0.0~quick: CWD: /home/raunakkathuria/Documents/technical/hapi-auth-jwt2
10 silly lifecycle hapi-auth-jwt2@10.0.0~quick: Args: [ '-c',
10 silly lifecycle   './node_modules/tape/bin/tape ./test/*.test.js | tap-nyc' ]
11 silly lifecycle hapi-auth-jwt2@10.0.0~quick: Returned: code: 1  signal: null
12 info lifecycle hapi-auth-jwt2@10.0.0~quick: Failed to exec quick script
13 verbose stack Error: hapi-auth-jwt2@10.0.0 quick: `./node_modules/tape/bin/tape ./test/*.test.js | tap-nyc`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid hapi-auth-jwt2@10.0.0
15 verbose cwd /home/raunakkathuria/Documents/technical/hapi-auth-jwt2
16 verbose Linux 4.15.0-96-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "quick"
18 verbose node v10.16.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error hapi-auth-jwt2@10.0.0 quick: `./node_modules/tape/bin/tape ./test/*.test.js | tap-nyc`
22 error Exit status 1
23 error Failed at the hapi-auth-jwt2@10.0.0 quick script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
nelsonic commented 4 years ago

@raunakkathuria thanks for reporting this issue. 👍

raunakkathuria commented 4 years ago

Found out the reason. I had version 10 of node installed. I should have read the compatibility section first. Upgraded to node 12+ and it works fine.

raunakkathuria commented 4 years ago

Added one minor PR - https://github.com/dwyl/hapi-auth-jwt2/pull/349