Hello guys!
I was installing hapi in the latest version and is giving this error:
`projeto/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:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)`
Package.json
{
"name": "projeto",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@hapi/hapi": "^19.0.5"
}
}
I changed the version to "藛18.3.1" and it worked correctly.
Hugs
@bognarjunior Hapi 19 support only node.js 12 or newer. Which do you use?
That's likely the correct answer. The issue template is there for a reason, please use it.
update your node version
Hello, I have this same error. I have confirmed I am running atleast node v12. I am not sure why this issue is present as there was no issues seconds before, then suddenly came up after making changes on unrelated code and restarting the project. I am going to try downgrading as hapi v19 is not exactly stable at the moment.
If you see this error, you are not using node 12, check again.
I have confirmed running node v12 (node -v). I installed nvm thinking it would help the problem, and installed v14. Confirmed running v14 afterwards. It did not fix the issue. Unless you have another way to detect node version, that would be helpful, to my knowledge I am running above node v12.
Downgrading hapi fixes this issue. Ideally this shouldn't be a problem to begin with.
I had a co-worker report the same. First thing he verified was using Node 12 and still saw the same issue, though I have not been able to repro from my machine. There may be some unique setup that causes this to happen.
I don't trust node -v, logging process.version inside your code is the only way to be sure.
@Marsup process.version yields v14.4.0 just the same as what node -v says.
Then you'll have to provide a project where we can reproduce that, so far it has never been the case.
Most helpful comment
@bognarjunior Hapi 19 support only node.js 12 or newer. Which do you use?