node.js – How to force my project to use newer node 14.x?
My application is launched by either npm start or yarn start which defined as:
"start": "node scripts/start.js" which leads to some boilerplate script to start stuff.
Failed to compile.
./src/components/Something/Something.js
Syntax error: Unexpected token (8:16)
6 | function testOptionalChaining(id, items) {
7 | return filter(items,(item) => {
> 8 | return item?.id == id
| ^
9 | })
My local has nvm manager installed, with several installed but v14.19.3 the one in use, also confirmed with
❯ npm --version
6.14.17
❯ node -v
v14.19.3
I have done some reading, and tried adding in my composer.json:
"engines": {
"node": ">=14.5.0"
},
As well as .npmrc file with engine-strict=true
Followed by removal of node_modules and npm install
However the compiling error is still there, I’ve also tested by updating our Dockerfile to FROM node:14-slim AS node and letting our CI build it with the above modifications, just on the off chance its something local – but the build pipeline returns the same error.
I am at a loss what else to try, I really want the optional chaining available to me!
Read more here: Source link
